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:
parent
4b838659e9
commit
526cd62075
1 changed files with 3 additions and 1 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue