diff --git a/AUTHORS.txt b/AUTHORS.txt index 0c3e2eb2b8..462385813c 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -27,3 +27,4 @@ CONTRIBUTORS ordered by first contribution. * panda1986<542638787@qq.com> "Bug fixed" * YueHonghui "Bug fixed" * ThomasDreibholz "IPv6 support" +* JuntaoLiu "Bug fixed" diff --git a/README.md b/README.md index b501fa3ea1..25967823bb 100755 --- a/README.md +++ b/README.md @@ -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 * v2.0, 2017-06-10, [2.0 release2(2.0.243)][r2.0r2] released. 86670 lines. @@ -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 diff --git a/trunk/src/app/srs_app_listener.cpp b/trunk/src/app/srs_app_listener.cpp index 9edb96f57a..0f9d965ccf 100755 --- a/trunk/src/app/srs_app_listener.cpp +++ b/trunk/src/app/srs_app_listener.cpp @@ -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); diff --git a/trunk/src/core/srs_core_performance.hpp b/trunk/src/core/srs_core_performance.hpp index 3dcf6e9b2b..2543832772 100644 --- a/trunk/src/core/srs_core_performance.hpp +++ b/trunk/src/core/srs_core_performance.hpp @@ -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 diff --git a/trunk/src/kernel/srs_kernel_error.hpp b/trunk/src/kernel/srs_kernel_error.hpp index 37cf65f936..200f8330dd 100644 --- a/trunk/src/kernel/srs_kernel_error.hpp +++ b/trunk/src/kernel/srs_kernel_error.hpp @@ -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.