mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix mem leak of encoder, edge and source. add destroy for gmc to detect mem leak. to 0.9.89
This commit is contained in:
parent
9a1c478266
commit
96a5c7b1ab
11 changed files with 145 additions and 90 deletions
|
@ -35,26 +35,59 @@ SrsConnection::SrsConnection(SrsServer* srs_server, st_netfd_t client_stfd)
|
|||
server = srs_server;
|
||||
stfd = client_stfd;
|
||||
connection_id = 0;
|
||||
pthread = new SrsThread(this, 0);
|
||||
}
|
||||
|
||||
SrsConnection::~SrsConnection()
|
||||
{
|
||||
srs_freepa(ip);
|
||||
srs_close_stfd(stfd);
|
||||
stop();
|
||||
}
|
||||
|
||||
int SrsConnection::start()
|
||||
{
|
||||
return pthread->start();
|
||||
}
|
||||
|
||||
int SrsConnection::cycle()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if (st_thread_create(cycle_thread, this, 0, 0) == NULL) {
|
||||
ret = ERROR_ST_CREATE_CYCLE_THREAD;
|
||||
srs_error("st_thread_create conn cycle thread error. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
srs_verbose("create st conn cycle thread success.");
|
||||
_srs_context->generate_id();
|
||||
connection_id = _srs_context->get_id();
|
||||
|
||||
return ret;
|
||||
ret = do_cycle();
|
||||
|
||||
// if socket io error, set to closed.
|
||||
if (srs_is_client_gracefully_close(ret)) {
|
||||
ret = ERROR_SOCKET_CLOSED;
|
||||
}
|
||||
|
||||
// success.
|
||||
if (ret == ERROR_SUCCESS) {
|
||||
srs_trace("client process normally finished. ret=%d", ret);
|
||||
}
|
||||
|
||||
// client close peer.
|
||||
if (ret == ERROR_SOCKET_CLOSED) {
|
||||
srs_warn("client disconnect peer. ret=%d", ret);
|
||||
}
|
||||
|
||||
// set loop to stop to quit.
|
||||
pthread->stop_loop();
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
void SrsConnection::on_thread_stop()
|
||||
{
|
||||
server->remove(this);
|
||||
}
|
||||
|
||||
void SrsConnection::stop()
|
||||
{
|
||||
srs_close_stfd(stfd);
|
||||
srs_freep(pthread);
|
||||
srs_freepa(ip);
|
||||
}
|
||||
|
||||
int SrsConnection::get_peer_ip()
|
||||
|
@ -92,40 +125,3 @@ int SrsConnection::get_peer_ip()
|
|||
return ret;
|
||||
}
|
||||
|
||||
void SrsConnection::cycle()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
_srs_context->generate_id();
|
||||
connection_id = _srs_context->get_id();
|
||||
|
||||
ret = do_cycle();
|
||||
|
||||
// if socket io error, set to closed.
|
||||
if (srs_is_client_gracefully_close(ret)) {
|
||||
ret = ERROR_SOCKET_CLOSED;
|
||||
}
|
||||
|
||||
// success.
|
||||
if (ret == ERROR_SUCCESS) {
|
||||
srs_trace("client process normally finished. ret=%d", ret);
|
||||
}
|
||||
|
||||
// client close peer.
|
||||
if (ret == ERROR_SOCKET_CLOSED) {
|
||||
srs_warn("client disconnect peer. ret=%d", ret);
|
||||
}
|
||||
|
||||
server->remove(this);
|
||||
}
|
||||
|
||||
void* SrsConnection::cycle_thread(void* arg)
|
||||
{
|
||||
SrsConnection* conn = (SrsConnection*)arg;
|
||||
srs_assert(conn != NULL);
|
||||
|
||||
conn->cycle();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue