Merge #1044, for #1045, set TCP SO_KEEPALIVE

pull/1080/head
winlin 7 years ago
commit 049e7c82c0

@ -27,3 +27,4 @@ CONTRIBUTORS ordered by first contribution.
* panda1986<542638787@qq.com> "Bug fixed"
* YueHonghui<hongf.yue@hotmail.com> "Bug fixed"
* ThomasDreibholz<dreibh@simula.no> "IPv6 support"
* JuntaoLiu<juntliu@gmail.com> "Bug fixed"

@ -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>
@ -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

@ -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);

@ -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

@ -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.

Loading…
Cancel
Save