mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +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()
|
SrsConnection::~SrsConnection()
|
||||||
{
|
{
|
||||||
|
if (stfd) {
|
||||||
|
st_netfd_close(stfd);
|
||||||
|
stfd = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsConnection::start()
|
int SrsConnection::start()
|
||||||
|
@ -59,7 +63,7 @@ void SrsConnection::cycle()
|
||||||
|
|
||||||
// success.
|
// success.
|
||||||
if (ret == ERROR_SUCCESS) {
|
if (ret == ERROR_SUCCESS) {
|
||||||
SrsInfo("client process normally finished. ret=%d", ret);
|
SrsTrace("client process normally finished. ret=%d", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
// client close peer.
|
// client close peer.
|
||||||
|
|
|
@ -148,6 +148,8 @@ void SrsServer::remove(SrsConnection* conn)
|
||||||
conns.erase(it);
|
conns.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SrsInfo("conn removed. conns=%d", (int)conns.size());
|
||||||
|
|
||||||
// all connections are created by server,
|
// all connections are created by server,
|
||||||
// so we delete it here.
|
// so we delete it here.
|
||||||
delete conn;
|
delete conn;
|
||||||
|
@ -161,11 +163,13 @@ int SrsServer::accept_client(st_netfd_t client_stfd)
|
||||||
|
|
||||||
// directly enqueue, the cycle thread will remove the client.
|
// directly enqueue, the cycle thread will remove the client.
|
||||||
conns.push_back(conn);
|
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.
|
// cycle will start process thread and when finished remove the client.
|
||||||
if ((ret = conn->start()) != ERROR_SUCCESS) {
|
if ((ret = conn->start()) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
SrsVerbose("conn start finished. ret=%d", ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -182,13 +186,14 @@ void SrsServer::listen_cycle()
|
||||||
SrsWarn("ignore accept thread stoppped for accept client error");
|
SrsWarn("ignore accept thread stoppped for accept client error");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
SrsVerbose("get a client. fd=%d", st_netfd_fileno(client_stfd));
|
||||||
|
|
||||||
if ((ret = accept_client(client_stfd)) != ERROR_SUCCESS) {
|
if ((ret = accept_client(client_stfd)) != ERROR_SUCCESS) {
|
||||||
SrsWarn("accept client error. ret=%d", ret);
|
SrsWarn("accept client error. ret=%d", ret);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsVerbose("accept client finished. ret=%d", ret);
|
SrsVerbose("accept client finished. conns=%d, ret=%d", (int)conns.size(), ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue