Added connection timeout for progressive HTTP connections.
This commit is contained in:
		
							parent
							
								
									18fa38a5cc
								
							
						
					
					
						commit
						63913f361a
					
				
					 1 changed files with 6 additions and 0 deletions
				
			
		|  | @ -529,14 +529,20 @@ namespace Connector_HTTP { | ||||||
|         Socket::Connection * myConn = myCConn->conn; |         Socket::Connection * myConn = myCConn->conn; | ||||||
|         myCConn->conn = new Socket::Connection(); |         myCConn->conn = new Socket::Connection(); | ||||||
|         myCConn->inUse.unlock(); |         myCConn->inUse.unlock(); | ||||||
|  |         long long int last_data_time = Util::getMS(); | ||||||
|         //continue sending data from this socket and keep it permanently in use
 |         //continue sending data from this socket and keep it permanently in use
 | ||||||
|         while (myConn->connected() && conn->connected()){ |         while (myConn->connected() && conn->connected()){ | ||||||
|           if (myConn->Received().size() || myConn->spool()){ |           if (myConn->Received().size() || myConn->spool()){ | ||||||
|             //forward any and all incoming data directly without parsing
 |             //forward any and all incoming data directly without parsing
 | ||||||
|             conn->SendNow(myConn->Received().get()); |             conn->SendNow(myConn->Received().get()); | ||||||
|             myConn->Received().get().clear(); |             myConn->Received().get().clear(); | ||||||
|  |             last_data_time = Util::getMS(); | ||||||
|           }else{ |           }else{ | ||||||
|             Util::sleep(30); |             Util::sleep(30); | ||||||
|  |             //if no data for 5000ms, cancel the connection
 | ||||||
|  |             if (Util::getMS() - last_data_time > 5000){ | ||||||
|  |               break; | ||||||
|  |             } | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|         myConn->close(); |         myConn->close(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Thulinma
						Thulinma