]> git.vomp.tv Git - vompserver.git/commitdiff
Server side timeouts
authorChris Tallon <chris@vomp.tv>
Sun, 1 Jun 2008 15:29:35 +0000 (15:29 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 1 Jun 2008 15:29:35 +0000 (15:29 +0000)
tcp.c
tcp.h
vompclient.c

diff --git a/tcp.c b/tcp.c
index 9fdcf568900631d469a27e5cdc1968c821c3b2a6..fb1a86080ee2a131a2dc2238afd0a2739bca7b99 100644 (file)
--- a/tcp.c
+++ b/tcp.c
@@ -125,6 +125,7 @@ int TCP::isConnected()
   return connected;
 }
 
+/*
 UCHAR* TCP::receivePacket()
 {
   if (!connected) return NULL;
@@ -157,6 +158,7 @@ UCHAR* TCP::receivePacket()
   dataLength = packetLength;
   return buffer;
 }
+*/
 
 int TCP::getDataLength()
 {
@@ -182,13 +184,13 @@ int TCP::readData(UCHAR* buffer, int totalBytes)
   {
     FD_ZERO(&readSet);
     FD_SET(sock, &readSet);
-    timeout.tv_sec = 10;
+    timeout.tv_sec = 20;
     timeout.tv_usec = 0;
     success = select(sock + 1, &readSet, NULL, NULL, passToSelect);
     if (success < 1)
     {
-      cleanup();
-      log->log("TCP", Log::DEBUG, "TCP: error or timeout");
+//      cleanup();
+      log->log("TCP", Log::DEBUG, "Select finished with %i", success);
       return 0;  // error, or timeout
     }
 
diff --git a/tcp.h b/tcp.h
index 4364798abf3a1e0a141dd4f353f3559d6dfb022c..7f33645a1f630286512e295dacf5113d1074ae75 100644 (file)
--- a/tcp.h
+++ b/tcp.h
@@ -59,7 +59,7 @@ class TCP
 
     int connectTo(char *host, unsigned short port);
     int sendPacket(UCHAR*, size_t size);
-    UCHAR* receivePacket();
+//    UCHAR* receivePacket();
     int readData(UCHAR* buffer, int totalBytes);
     
     // Get methods
index 2b28b971b12c2eb4cdb43b563440eba6550ef102..4a2692cf767a09758db097efa45b8a4f69a3ee2c 100644 (file)
@@ -162,9 +162,9 @@ void VompClient::run2()
   pthread_sigmask(SIG_BLOCK, &sigset, NULL);
   pthread_detach(runThread);  // Detach
 
-  tcp.disableReadTimeout();
+//  tcp.disableReadTimeout();
 
-  tcp.setSoKeepTime(3);
+//  tcp.setSoKeepTime(3);
   tcp.setNonBlocking();
 
   ULONG channelID;
@@ -179,7 +179,18 @@ void VompClient::run2()
   {
     log->log("Client", Log::DEBUG, "Waiting");
     
-    if (!tcp.readData((UCHAR*)&channelID, sizeof(ULONG))) break;
+    if (!tcp.readData((UCHAR*)&channelID, sizeof(ULONG)))
+    {
+      // If this read fails then the client just hasn't sent anything.
+      // If any of the lower reads fail, then break, the connection is probably dead
+
+      // check connection is ok
+//      if (tcp.isConnected()) continue;
+      
+      log->log("Client", Log::DEBUG, "Disconnection detected");
+      break;
+    }     
+    
     channelID = ntohl(channelID);
     if (channelID == 1)
     {