Added 5 minute timeout to idle connections
This commit is contained in:
parent
b106a1eede
commit
40f1cec8f9
2 changed files with 10 additions and 2 deletions
|
@ -44,6 +44,7 @@ namespace Mist{
|
|||
maxSkipAhead = 7500;
|
||||
minSkipAhead = 5000;
|
||||
realTime = 1000;
|
||||
lastRecv = Util::epoch();
|
||||
if (myConn){
|
||||
setBlocking(true);
|
||||
}else{
|
||||
|
@ -658,11 +659,17 @@ namespace Mist{
|
|||
static bool firstData = true;//only the first time, we call onRequest if there's data buffered already.
|
||||
if ((firstData && myConn.Received().size()) || myConn.spool()){
|
||||
firstData = false;
|
||||
DEBUG_MSG(DLVL_DONTEVEN, "onRequest");
|
||||
DONTEVEN_MSG("onRequest");
|
||||
onRequest();
|
||||
lastRecv = Util::epoch();
|
||||
}else{
|
||||
if (!isBlocking && !parseData){
|
||||
Util::sleep(500);
|
||||
if (Util::epoch() - lastRecv > 300){
|
||||
WARN_MSG("Disconnecting 5 minute idle connection");
|
||||
myConn.close();
|
||||
}else{
|
||||
Util::sleep(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ namespace Mist {
|
|||
std::map<unsigned long, unsigned long> nxtKeyNum;///< Contains the number of the next key, for page seeking purposes.
|
||||
std::set<sortedPageInfo> buffer;///< A sorted list of next-to-be-loaded packets.
|
||||
bool sought;///<If a seek has been done, this is set to true. Used for seeking on prepareNext().
|
||||
uint64_t lastRecv;
|
||||
protected://these are to be messed with by child classes
|
||||
virtual std::string getConnectedHost();
|
||||
virtual std::string getConnectedBinHost();
|
||||
|
|
Loading…
Add table
Reference in a new issue