1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Fix FD leak when exceed max connections limit. (#2925)

* fix fd leak

when tcp connection exceed max_connection, that connection will leak because of not closing the fd

* fix leak, code refine
This commit is contained in:
Matthew 2022-02-26 07:50:09 +08:00 committed by GitHub
parent 4b838659e9
commit 526cd62075
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1374,8 +1374,10 @@ srs_error_t SrsServer::accept_client(SrsListenerType type, srs_netfd_t stfd)
ISrsStartableConneciton* conn = NULL;
if ((err = fd_to_resource(type, stfd, &conn)) != srs_success) {
//close fd on conn error, otherwise will lead to fd leak -gs
srs_close_stfd(stfd);
if (srs_error_code(err) == ERROR_SOCKET_GET_PEER_IP && _srs_config->empty_ip_ok()) {
srs_close_stfd(stfd); srs_error_reset(err);
srs_error_reset(err);
return srs_success;
}
return srs_error_wrap(err, "fd to resource");