Author: rjung
Date: Sat Nov 18 06:26:01 2006
New Revision: 476528

URL: http://svn.apache.org/viewvc?view=rev&rev=476528
Log:
Minor cleanups of socket handling
- use JK_INVALID_SOCKET instead of -1 in all places
- use 0 instead of -1 as default value of socket_timeout
- all timeouts now are disabled with the value 0 and negative
  values should behave the same, so only compare timeouts with
  - > 0
  - <= 0
- remove redundant check for cache_timeout > 0 in ajp_maintain

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
    tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c?view=diff&rev=476528&r1=476527&r2=476528
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Sat Nov 18 
06:26:01 2006
@@ -685,7 +685,7 @@
         if (JK_IS_DEBUG_LEVEL(l))
             jk_log(l, JK_LOG_DEBUG,
             "reset socket with sd = %u", ae->sd );
-        ae->sd = -1;
+        ae->sd = JK_INVALID_SOCKET;
     }
     jk_reset_pool(&(ae->pool));
 }
@@ -1166,7 +1166,7 @@
     while (IS_VALID_SOCKET(ae->sd)) {
         int rc = 0;
         err = 0;
-        if (ae->worker->socket_timeout) {
+        if (ae->worker->socket_timeout > 0) {
             if (!jk_is_socket_connected(ae->sd)) {
                 jk_log(l, JK_LOG_INFO,
                        "(%s) socket %d is not connected any more (errno=%d)",
@@ -1176,7 +1176,7 @@
                 err++;
             }
         }
-        if (ae->worker->prepost_timeout != 0 && !err) {
+        if (ae->worker->prepost_timeout > 0 && !err) {
             /* handle cping/cpong if prepost_timeout is set
              * If the socket is disconnected no need to handle
              * the cping/cpong
@@ -1233,7 +1233,7 @@
             if (ajp_connection_tcp_send_message(ae, op->request, l) != 
JK_TRUE) {
                 /* Close the socket if unable to send request */
                 jk_close_socket(ae->sd);
-                ae->sd = -1;
+                ae->sd = JK_INVALID_SOCKET;
                 jk_log(l, JK_LOG_INFO,
                        "(%s) error sending request on a fresh connection 
(errno=%d)",
                        ae->worker->name, ae->last_errno);
@@ -1297,7 +1297,7 @@
             if (ajp_connection_tcp_send_message(ae, s->reco_buf, l) != 
JK_TRUE) {
                 /* Close the socket if unable to send request */
                 jk_close_socket(ae->sd);
-                ae->sd = -1;
+                ae->sd = JK_INVALID_SOCKET;
                 jk_log(l, JK_LOG_ERROR,
                        "(%s) failed resending request body (lb mode) (%d)",
                        ae->worker->name, postlen);
@@ -1347,7 +1347,7 @@
             if (ajp_connection_tcp_send_message(ae, op->post, l) != JK_TRUE) {
                 /* Close the socket if unable to send request */
                 jk_close_socket(ae->sd);
-                ae->sd = -1;
+                ae->sd = JK_INVALID_SOCKET;
                 jk_log(l, JK_LOG_ERROR, "(%s) error sending request body",
                        ae->worker->name);
                 JK_TRACE_EXIT(l);
@@ -1527,7 +1527,7 @@
         int rc = 0;
 
         /* If we set a reply timeout, check it something is available */
-        if (p->worker->reply_timeout != 0) {
+        if (p->worker->reply_timeout > 0) {
             if (ajp_is_input_event(p, p->worker->reply_timeout, l) ==
                 JK_FALSE) {
                 jk_log(l, JK_LOG_ERROR,
@@ -2319,7 +2319,7 @@
         ajp_worker_t *aw = pThis->worker_private;
         int rc;
         /* Obtain current time only if needed */
-        if (aw->cache_timeout < 1) {
+        if (aw->cache_timeout <= 0) {
             /* Nothing to do. */
             JK_TRACE_EXIT(l);
             return JK_TRUE;
@@ -2327,7 +2327,7 @@
         JK_ENTER_CS(&aw->cs, rc);
         if (rc) {
             unsigned int i, n = 0, cnt = 0;
-            /* Count opended slots */
+            /* Count open slots */
             for (i = 0; i < aw->ep_cache_sz; i++) {
                 if (aw->ep_cache[i] && IS_VALID_SOCKET(aw->ep_cache[i]->sd))
                     cnt++;
@@ -2337,7 +2337,7 @@
                 /* Skip the closed sockets */
                 if (aw->ep_cache[i] && IS_VALID_SOCKET(aw->ep_cache[i]->sd)) {
                     int elapsed = (int)difftime(now, 
aw->ep_cache[i]->last_access);
-                    if ((aw->cache_timeout > 0) && (elapsed > 
aw->cache_timeout)) {
+                    if (elapsed > aw->cache_timeout) {
                         time_t rt = 0;
                         n++;
                         if (JK_IS_DEBUG_LEVEL(l))

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h?view=diff&rev=476528&r1=476527&r2=476528
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h Sat Nov 18 
06:26:01 2006
@@ -195,7 +195,7 @@
 #define AJP_DEF_REPLY_TIMEOUT     (0)   /* NO REPLY TIMEOUT                    
    */
 #define AJP_DEF_PREPOST_TIMEOUT   (0)   /* NO PREPOST TIMEOUT => NO 
CPING/CPONG    */
 #define AJP_DEF_RECOVERY_OPTS     (0)   /* NO RECOVERY / NO    */
-#define AJP_DEF_SOCKET_TIMEOUT    (-1)  /* No timeout */
+#define AJP_DEF_SOCKET_TIMEOUT    (0)  /* No timeout */
 
 #define RECOVER_ABORT_IF_TCGETREQUEST    0x0001 /* DONT RECOVER IF TOMCAT FAIL 
AFTER RECEIVING REQUEST */
 #define RECOVER_ABORT_IF_TCSENDHEADER    0x0002 /* DONT RECOVER IF TOMCAT FAIL 
AFTER SENDING HEADERS */



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to