Make HTTP proxy insta-murder connections that need to be re-used (happens when progressive makes two connections from one user agent for some reason - kills the oldest connections for the newest one).
This commit is contained in:
parent
469d810d6b
commit
607a41c443
1 changed files with 10 additions and 1 deletions
|
@ -159,9 +159,18 @@ namespace Connector_HTTP{
|
|||
std::string request = H.BuildRequest();//copy the request for later forwarding to the connector
|
||||
H.Clean();
|
||||
|
||||
//existing connections must be murdered, if any
|
||||
if (connconn.count(uid)){
|
||||
if (!connconn[uid]->in_use.try_lock()){
|
||||
connconn[uid]->conn->close();
|
||||
connconn[uid]->in_use.lock();
|
||||
}
|
||||
connconn[uid]->in_use.unlock();
|
||||
}
|
||||
//check if a connection exists, and if not create one
|
||||
conn_mutex.lock();
|
||||
if (!connconn.count(uid)){
|
||||
if (!connconn.count(uid) || !connconn[uid]->conn->connected()){
|
||||
if (connconn.count(uid)){connconn.erase(uid);}
|
||||
connconn[uid] = new ConnConn(new Socket::Connection("/tmp/mist/http_"+connector));
|
||||
connconn[uid]->conn->setBlocking(false);//do not block on spool() with no data
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue