From 59b21d94ec892bfc6c841c80da7b6a57db73d926 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Wed, 28 Aug 2013 15:49:45 +0200 Subject: [PATCH] Fixed HTTP proxy not correctly handling connectors that disconnect in between handling requests. --- src/connectors/conn_http.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/connectors/conn_http.cpp b/src/connectors/conn_http.cpp index 2a6d50c7..6a70c017 100644 --- a/src/connectors/conn_http.cpp +++ b/src/connectors/conn_http.cpp @@ -391,7 +391,7 @@ namespace Connector_HTTP { //check if a connection exists, and if not create one connMutex.lock(); - if ( !connectorConnections.count(uid) || !connectorConnections[uid]->conn->connected()){ + if ( !connectorConnections.count(uid) || (!connectorConnections[uid]->conn->spool() && !connectorConnections[uid]->conn->connected())){ if (connectorConnections.count(uid)){ delete connectorConnections[uid]; connectorConnections.erase(uid); @@ -462,18 +462,17 @@ namespace Connector_HTTP { } break; //continue down below this while loop } + } + //keep trying unless the timeout triggers + if (timeout++ > 4000){ + std::cout << "[20s timeout triggered]" << std::endl; + myCConn->conn->close(); + myCConn->inUse.unlock(); + //unset to only read headers + H.headerOnly = false; + return proxyHandleTimeout(H, conn); }else{ - //keep trying unless the timeout triggers - if (timeout++ > 4000){ - std::cout << "[20s timeout triggered]" << std::endl; - myCConn->conn->close(); - myCConn->inUse.unlock(); - //unset to only read headers - H.headerOnly = false; - return proxyHandleTimeout(H, conn); - }else{ - Util::sleep(5); - } + Util::sleep(5); } } //unset to only read headers