mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 11:21:52 +00:00
close fd when delete connection object
This commit is contained in:
parent
973bea1e14
commit
96e1de255c
2 changed files with 11 additions and 2 deletions
|
@ -35,6 +35,10 @@ SrsConnection::SrsConnection(SrsServer* srs_server, st_netfd_t client_stfd)
|
|||
|
||||
SrsConnection::~SrsConnection()
|
||||
{
|
||||
if (stfd) {
|
||||
st_netfd_close(stfd);
|
||||
stfd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int SrsConnection::start()
|
||||
|
@ -59,7 +63,7 @@ void SrsConnection::cycle()
|
|||
|
||||
// success.
|
||||
if (ret == ERROR_SUCCESS) {
|
||||
SrsInfo("client process normally finished. ret=%d", ret);
|
||||
SrsTrace("client process normally finished. ret=%d", ret);
|
||||
}
|
||||
|
||||
// client close peer.
|
||||
|
|
|
@ -148,6 +148,8 @@ void SrsServer::remove(SrsConnection* conn)
|
|||
conns.erase(it);
|
||||
}
|
||||
|
||||
SrsInfo("conn removed. conns=%d", (int)conns.size());
|
||||
|
||||
// all connections are created by server,
|
||||
// so we delete it here.
|
||||
delete conn;
|
||||
|
@ -161,11 +163,13 @@ int SrsServer::accept_client(st_netfd_t client_stfd)
|
|||
|
||||
// directly enqueue, the cycle thread will remove the client.
|
||||
conns.push_back(conn);
|
||||
SrsVerbose("add conn to vector. conns=%d", (int)conns.size());
|
||||
|
||||
// cycle will start process thread and when finished remove the client.
|
||||
if ((ret = conn->start()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
SrsVerbose("conn start finished. ret=%d", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -182,13 +186,14 @@ void SrsServer::listen_cycle()
|
|||
SrsWarn("ignore accept thread stoppped for accept client error");
|
||||
continue;
|
||||
}
|
||||
SrsVerbose("get a client. fd=%d", st_netfd_fileno(client_stfd));
|
||||
|
||||
if ((ret = accept_client(client_stfd)) != ERROR_SUCCESS) {
|
||||
SrsWarn("accept client error. ret=%d", ret);
|
||||
continue;
|
||||
}
|
||||
|
||||
SrsVerbose("accept client finished. ret=%d", ret);
|
||||
SrsVerbose("accept client finished. conns=%d, ret=%d", (int)conns.size(), ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue