if (*i == edr) break; // found
}
- if (i == receivers.end()) return; // Not in the list. Already unregistered? Perhaps vdr::connectionDied already removed this streamclient
+ // Not in the list. Already unregistered? Perhaps vdr::connectionDied already removed this streamclient
// FIXME, this should probably be done another way. A call to edUnregister with an object that may or may not be in the list? Not good.
+ if (i == receivers.end())
+ {
+ edUnlock();
+ return;
+ }
if (!edr->callinprogress)
{
while(1)
{
- if (!tcp->readData((UCHAR*)&channelID, sizeof(ULONG))) // 2s timeout atm
+ if (!tcp->readData((UCHAR*)&channelID, sizeof(ULONG))) // 2s timeout atm
{
++timeoutCount;
if (!tcp->isConnected()) { connectionDied(); return; } // return to stop this thread
- timeoutCount = 0; // disable it for now
+ timeoutCount = 0; // disable it for now
- if (timeoutCount >= 10) //20s
+ if (timeoutCount >= 3) // x2 for seconds
{
timeNow = (ULONG)time(NULL);
- if (lastKAsent > (timeNow - 20)) continue;
+ if (lastKAsent > (timeNow - 6)) continue;
if (lastKAsent == 0)
{
- logger->log("VDR", Log::DEBUG, "Sending KA packet");
- if (!sendKA(timeNow)) { connectionDied(); return; }
+ logger->log("VDR", Log::DEBUG, "(Not actually) Sending KA packet");
+// if (!sendKA(timeNow))
+// {
+// logger->log("VDR", Log::DEBUG, "Could not send KA, calling connectionDied");
+// connectionDied();
+// return;
+// }
lastKAsent = timeNow;
continue;
}
- if (lastKAsent <= (timeNow - 20)) { connectionDied(); return; }
+ if (lastKAsent <= (timeNow - 6))
+ {
+ logger->log("VDR", Log::DEBUG, "lastKA over 20s ago, calling connectionDied");
+ connectionDied();
+ return;
+ }
}
continue;
}
// Data was read
-
+
timeoutCount = 0;
channelID = ntohl(channelID);
// If RR, the individual protocol functions must delete vresp.
// If stream, the data and length is taken out in ed_cb_call and vresp is deleted there.
}
+
+ connectionDied();
}
void VDR::connectionDied()
}
edUnlock();
// Ok, all event receviers should be dealt with. just in case there weren't any, inform command
-
+ logger->log("VDR", Log::DEBUG, "edUnlock at end of connectionDied");
+
Command::getInstance()->connectionLost();
}
// vdrpr.requestTime = time(NULL);
vdrpr.receiverChannel = VDR::CHANNEL_REQUEST_RESPONSE;
vdrpr.requestSerialNumber = vrp->getSerial();
+
edRegister(&vdrpr);
-
+
edLock();
+
if ((ULONG)tcp->sendData(vrp->getPtr(), vrp->getLen()) != vrp->getLen())
{
edUnlock();