Skip to content

Commit

Permalink
Merge #1044, for #1045, set TCP SO_KEEPALIVE
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jan 7, 2018
2 parents 1aa36f3 + 911cd44 commit 049e7c8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ CONTRIBUTORS ordered by first contribution.
* panda1986<[email protected]> "Bug fixed"
* YueHonghui<[email protected]> "Bug fixed"
* ThomasDreibholz<[email protected]> "IPv6 support"
* JuntaoLiu<[email protected]> "Bug fixed"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ Please select according to languages:

### V2 changes

* v2.0, 2018-01-07, Merge [#1045][bug #1045], fix [#1044][bug #1044], TCP connection alive detection. 2.0.245
* v2.0, 2018-01-04, Merge [#1039][bug #1039], fix bug of init.d script.
* v2.0, 2018-01-01, Merge [#1033][bug #1033], allow user to add some specific flags. 2.0.244
* <strong>v2.0, 2017-06-10, [2.0 release2(2.0.243)][r2.0r2] released. 86670 lines.</strong>
Expand Down Expand Up @@ -1421,6 +1422,8 @@ Winlin
[bug #899]: https://github.com/ossrs/srs/issues/899
[bug #1033]: https://github.com/ossrs/srs/issues/1033
[bug #1039]: https://github.com/ossrs/srs/issues/1039
[bug #1044]: https://github.com/ossrs/srs/issues/1044
[bug #1045]: https://github.com/ossrs/srs/issues/1045
[bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx

[bug #735]: https://github.com/ossrs/srs/issues/735
Expand Down
7 changes: 7 additions & 0 deletions trunk/src/app/srs_app_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ srs_error_t SrsTcpListener::listen()
if ((_fd = socket(r->ai_family, r->ai_socktype, r->ai_protocol)) == -1) {
return srs_error_new(ERROR_SOCKET_CREATE, "create socket. ip=%s, port=%d", ip.c_str(), port);
}

#ifdef SRS_PERF_SO_KEEPALIVE
int tcp_keepalive = 1;
if (setsockopt(_fd, SOL_SOCKET, SO_KEEPALIVE, &tcp_keepalive, sizeof(int)) == -1) {
return srs_error_new(ERROR_SOCKET_SETKEEPALIVE, "setsockopt SO_KEEPALIVE[%d]error. port=%d", tcp_keepalive, port);
}
#endif

srs_fd_close_exec(_fd);
srs_socket_reuse_addr(_fd);
Expand Down
4 changes: 4 additions & 0 deletions trunk/src/core/srs_core_performance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,9 @@
#define SRS_PERF_GLIBC_MEMORY_CHECK
#undef SRS_PERF_GLIBC_MEMORY_CHECK

// Whether set SO_KEEPALIVE for TCP connection.
// @see https://github.com/ossrs/srs/issues/1044
#undef SRS_PERF_SO_KEEPALIVE

#endif

1 change: 1 addition & 0 deletions trunk/src/kernel/srs_kernel_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
#define ERROR_THREAD_DUMMY 1072
#define ERROR_ASPROCESS_PPID 1073
#define ERROR_EXCEED_CONNECTIONS 1074
#define ERROR_SOCKET_SETKEEPALIVE 1075

///////////////////////////////////////////////////////
// RTMP protocol error.
Expand Down

0 comments on commit 049e7c8

Please sign in to comment.