Fixed a few minor memory leaks in HTTP proxy.

This commit is contained in:
Thulinma 2013-04-06 22:23:10 +02:00
parent a0b1b1a8b3
commit 1945124ee9

View file

@ -305,6 +305,7 @@ namespace Connector_HTTP {
connMutex.lock(); connMutex.lock();
if ( !connectorConnections.count(uid) || !connectorConnections[uid]->conn->connected()){ if ( !connectorConnections.count(uid) || !connectorConnections[uid]->conn->connected()){
if (connectorConnections.count(uid)){ if (connectorConnections.count(uid)){
delete connectorConnections[uid];
connectorConnections.erase(uid); connectorConnections.erase(uid);
} }
connectorConnections[uid] = new ConnConn(new Socket::Connection("/tmp/mist/http_" + connector)); connectorConnections[uid] = new ConnConn(new Socket::Connection("/tmp/mist/http_" + connector));
@ -557,10 +558,15 @@ int main(int argc, char ** argv){
tthread::thread * T = new tthread::thread(Connector_HTTP::proxyHandleHTTPConnection, (void *)(new Socket::Connection(S))); tthread::thread * T = new tthread::thread(Connector_HTTP::proxyHandleHTTPConnection, (void *)(new Socket::Connection(S)));
//detach it, no need to keep track of it anymore //detach it, no need to keep track of it anymore
T->detach(); T->detach();
delete T;
}else{ }else{
Util::sleep(10); //sleep 10ms Util::sleep(10); //sleep 10ms
} }
} //while connected and not requested to stop } //while connected and not requested to stop
server_socket.close(); server_socket.close();
if (Connector_HTTP::timeouter){
Connector_HTTP::timeouter->detach();
delete Connector_HTTP::timeouter;
}
return 0; return 0;
} //main } //main