mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix #518, fix fd leak bug when fork. 2.0.200
This commit is contained in:
parent
803c899a9b
commit
2310b2da59
3 changed files with 24 additions and 15 deletions
|
@ -336,6 +336,7 @@ Remark:
|
||||||
|
|
||||||
## History
|
## History
|
||||||
|
|
||||||
|
* v2.0, 2015-11-16, for [#518][bug #518] fix fd leak bug when fork. 2.0.200
|
||||||
* v2.0, 2015-11-05, for [#511][bug #511] fix bug for restart thread. 2.0.199
|
* v2.0, 2015-11-05, for [#511][bug #511] fix bug for restart thread. 2.0.199
|
||||||
* v2.0, 2015-11-02, for [#515][bug #515] use srs_freepa and SrsAutoFreeA for array. 2.0.198
|
* v2.0, 2015-11-02, for [#515][bug #515] use srs_freepa and SrsAutoFreeA for array. 2.0.198
|
||||||
* v2.0, 2015-10-28, for [ExoPlayer #828][exo #828], remove duration for live.
|
* v2.0, 2015-10-28, for [ExoPlayer #828][exo #828], remove duration for live.
|
||||||
|
@ -1203,6 +1204,7 @@ Winlin
|
||||||
[bug #512]: https://github.com/ossrs/srs/issues/512
|
[bug #512]: https://github.com/ossrs/srs/issues/512
|
||||||
[bug #515]: https://github.com/ossrs/srs/issues/515
|
[bug #515]: https://github.com/ossrs/srs/issues/515
|
||||||
[bug #511]: https://github.com/ossrs/srs/issues/511
|
[bug #511]: https://github.com/ossrs/srs/issues/511
|
||||||
|
[bug #518]: https://github.com/ossrs/srs/issues/518
|
||||||
[bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx
|
[bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx
|
||||||
|
|
||||||
[exo #828]: https://github.com/google/ExoPlayer/pull/828
|
[exo #828]: https://github.com/google/ExoPlayer/pull/828
|
||||||
|
|
|
@ -1223,10 +1223,11 @@ void SrsServer::resample_kbps()
|
||||||
int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd)
|
int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
int fd = st_netfd_fileno(client_stfd);
|
int fd = st_netfd_fileno(client_stfd);
|
||||||
|
|
||||||
int max_connections = _srs_config->get_max_connections();
|
int max_connections = _srs_config->get_max_connections();
|
||||||
if ((int)conns.size() >= max_connections) {
|
if ((int)conns.size() >= max_connections) {
|
||||||
|
|
||||||
srs_error("exceed the max connections, drop client: "
|
srs_error("exceed the max connections, drop client: "
|
||||||
"clients=%d, max=%d, fd=%d", (int)conns.size(), max_connections, fd);
|
"clients=%d, max=%d, fd=%d", (int)conns.size(), max_connections, fd);
|
||||||
|
|
||||||
|
@ -1234,20 +1235,26 @@ int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
int val;
|
|
||||||
if ((val = fcntl(fd, F_GETFD, 0)) < 0) {
|
// avoid fd leak when fork.
|
||||||
ret = ERROR_SYSTEM_PID_GET_FILE_INFO;
|
// @see https://github.com/ossrs/srs/issues/518
|
||||||
srs_error("fnctl F_GETFD error! fd=%d. ret=%#x", fd, ret);
|
if (true) {
|
||||||
srs_close_stfd(client_stfd);
|
int val;
|
||||||
return ret;
|
if ((val = fcntl(fd, F_GETFD, 0)) < 0) {
|
||||||
|
ret = ERROR_SYSTEM_PID_GET_FILE_INFO;
|
||||||
|
srs_error("fnctl F_GETFD error! fd=%d. ret=%#x", fd, ret);
|
||||||
|
srs_close_stfd(client_stfd);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
val |= FD_CLOEXEC;
|
||||||
|
if (fcntl(fd, F_SETFD, val) < 0) {
|
||||||
|
ret = ERROR_SYSTEM_PID_SET_FILE_INFO;
|
||||||
|
srs_error("fcntl F_SETFD error! fd=%d ret=%#x", fd, ret);
|
||||||
|
srs_close_stfd(client_stfd);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val |= FD_CLOEXEC;
|
|
||||||
if (fcntl(fd, F_SETFD, val) < 0) {
|
|
||||||
ret = ERROR_SYSTEM_PID_SET_FILE_INFO;
|
|
||||||
srs_error("fcntl F_SETFD error! fd=%d ret=%#x", fd, ret);
|
|
||||||
srs_close_stfd(client_stfd);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
SrsConnection* conn = NULL;
|
SrsConnection* conn = NULL;
|
||||||
if (type == SrsListenerRtmpStream) {
|
if (type == SrsListenerRtmpStream) {
|
||||||
conn = new SrsRtmpConn(this, client_stfd);
|
conn = new SrsRtmpConn(this, client_stfd);
|
||||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR 2
|
#define VERSION_MAJOR 2
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 199
|
#define VERSION_REVISION 200
|
||||||
|
|
||||||
// server info.
|
// server info.
|
||||||
#define RTMP_SIG_SRS_KEY "SRS"
|
#define RTMP_SIG_SRS_KEY "SRS"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue