You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2006/07/08 08:46:06 UTC

svn commit: r420059 - /tomcat/connectors/trunk/jk/native/common/jk_connect.c

Author: mturk
Date: Fri Jul  7 23:46:06 2006
New Revision: 420059

URL: http://svn.apache.org/viewvc?rev=420059&view=rev
Log:
Use socket fake lingering only if we can set the socket timeout. It fixes the Solaris 8 minutes default
socket closing when Tomcat does not catch the FIN packet.

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_connect.c

Modified: tomcat/connectors/trunk/jk/native/common/jk_connect.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_connect.c?rev=420059&r1=420058&r2=420059&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_connect.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_connect.c Fri Jul  7 23:46:06 2006
@@ -488,6 +488,7 @@
     unsigned char dummy[512];
     int nbytes;
     int ttl = 0;
+    int rc = 0;
 #if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__))
     int tmout = SECONDS_TO_LINGER * 1000;
     if (s == INVALID_SOCKET)
@@ -504,19 +505,21 @@
         return jk_close_socket(s);
     }
 #if defined(WIN32)  || (defined(NETWARE) && defined(__NOVELL_LIBC__))
-    setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,
-               (const char *) &tmout, sizeof(int));
+    if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,
+                   (const char *) &tmout, sizeof(int)) == 0)
+        rc = 1;
 #elif defined(SO_RCVTIMEO) && defined(USE_SO_RCVTIMEO)
     tv.tv_sec  = SECONDS_TO_LINGER;
     tv.tv_usec = 0;
-    setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,
-               (const void *) &tv, sizeof(tv));
+    if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,
+                   (const void *) &tv, sizeof(tv)))
+        rc = 1;
 #endif
     /* Read all data from the peer until we reach "end-of-file" (FIN
      * from peer) or we've exceeded our overall timeout. If the client does
-     * not send us bytes within12 second, close the connection.
+     * not send us bytes within 12 second, close the connection.
      */
-    while (1) {
+    while (rc) {
         nbytes = jk_tcp_socket_recvfull(s, dummy, sizeof(dummy));
         if (nbytes <= 0)
             break;
@@ -659,7 +662,7 @@
     saved_errno = errno;
     soblock(sd);
     if (rd == -1 && saved_errno == EWOULDBLOCK) {
-    errno = 0;
+        errno = 0;
         return 1;
     }
     else {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org