tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r485147 - /tomcat/connectors/trunk/jni/native/src/network.c
Date Sun, 10 Dec 2006 08:51:32 GMT
Author: mturk
Date: Sun Dec 10 00:51:32 2006
New Revision: 485147

URL: http://svn.apache.org/viewvc?view=rev&rev=485147
Log:
Restore timeout after read(t) calls. Without restoring
that timeout was used for sendbb (in most cases 100ms)

Modified:
    tomcat/connectors/trunk/jni/native/src/network.c

Modified: tomcat/connectors/trunk/jni/native/src/network.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jni/native/src/network.c?view=diff&rev=485147&r1=485146&r2=485147
==============================================================================
--- tomcat/connectors/trunk/jni/native/src/network.c (original)
+++ tomcat/connectors/trunk/jni/native/src/network.c Sun Dec 10 00:51:32 2006
@@ -226,7 +226,7 @@
         s->sock = NULL;
         apr_socket_close(as);
     }
-    
+
     apr_pool_destroy(s->pool);
 }
 
@@ -701,14 +701,22 @@
     tcn_socket_t *s = J2P(sock, tcn_socket_t *);
     apr_size_t nbytes = (apr_size_t)toread;
     apr_status_t ss;
+    apr_interval_time_t pt;
+    apr_interval_time_t nt = J2T(timeout);
 
     UNREFERENCED(o);
     TCN_ASSERT(sock != 0);
     TCN_ASSERT(s->opaque != NULL);
     TCN_ASSERT(buf != NULL);
 
-    if ((ss = (*s->net->timeout_set)(s->opaque, J2T(timeout))) != APR_SUCCESS)
-        goto cleanup;
+    if ((ss = (*s->net->timeout_get)(s->opaque, &pt)) != APR_SUCCESS) {
+        TCN_ERROR_WRAP(ss);
+        return -(jint)ss;
+    }
+    if (pt != nt) {
+        if ((ss = (*s->net->timeout_set)(s->opaque, nt)) != APR_SUCCESS)
+            goto cleanup;
+    }
     if (toread <= TCN_BUFFER_SZ) {
         jbyte sb[TCN_BUFFER_SZ];
         if ((ss = (*s->net->recv)(s->opaque, sb, &nbytes)) == APR_SUCCESS)
@@ -722,6 +730,11 @@
             (*e)->SetByteArrayRegion(e, buf, offset, (jsize)nbytes, &sb[0]);
         free(sb);
     }
+    if (pt != nt) {
+        if ((ss = (*s->net->timeout_set)(s->opaque, pt)) != APR_SUCCESS)
+            goto cleanup;
+    }
+
 #ifdef TCN_DO_STATISTICS
     if (ss == APR_SUCCESS) {
         sp_max_recv = TCN_MAX(sp_max_recv, nbytes);
@@ -854,6 +867,8 @@
     apr_status_t ss;
     apr_size_t nbytes = (apr_size_t)len;
     char *bytes;
+    apr_interval_time_t pt;
+    apr_interval_time_t nt = J2T(timeout);
 
     UNREFERENCED(o);
     if (!sock) {
@@ -866,9 +881,24 @@
     bytes  = (char *)(*e)->GetDirectBufferAddress(e, buf);
     TCN_ASSERT(bytes != NULL);
 
-    if ((ss = (*s->net->timeout_set)(s->opaque, J2T(timeout))) != APR_SUCCESS)
-         return -(jint)ss;
+    if ((ss = (*s->net->timeout_get)(s->opaque, &pt)) != APR_SUCCESS) {
+        TCN_ERROR_WRAP(ss);
+        return -(jint)ss;
+    }
+    if (pt != nt) {
+        if ((ss = (*s->net->timeout_set)(s->opaque, nt)) != APR_SUCCESS) {
+            TCN_ERROR_WRAP(ss);
+            return -(jint)ss;
+        }
+    }
     ss = (*s->net->recv)(s->opaque, bytes + offset, &nbytes);
+    if (pt != nt) {
+        if ((ss = (*s->net->timeout_set)(s->opaque, pt)) != APR_SUCCESS) {
+            TCN_ERROR_WRAP(ss);
+            return -(jint)ss;
+        }
+    }
+
 #ifdef TCN_DO_STATISTICS
     if (ss == APR_SUCCESS) {
         sp_max_recv = TCN_MAX(sp_max_recv, nbytes);
@@ -905,6 +935,8 @@
     tcn_socket_t *s = J2P(sock, tcn_socket_t *);
     apr_status_t ss;
     apr_size_t nbytes = (apr_size_t)len;
+    apr_interval_time_t pt;
+    apr_interval_time_t nt = J2T(timeout);
 
     UNREFERENCED_STDARGS;
     UNREFERENCED(o);
@@ -916,9 +948,24 @@
     TCN_ASSERT(s->opaque != NULL);
 
 
-    if ((ss = (*s->net->timeout_set)(s->opaque, J2T(timeout))) != APR_SUCCESS)
-         return -(jint)ss;
+    if ((ss = (*s->net->timeout_get)(s->opaque, &pt)) != APR_SUCCESS) {
+        TCN_ERROR_WRAP(ss);
+        return -(jint)ss;
+    }
+    if (pt != nt) {
+        if ((ss = (*s->net->timeout_set)(s->opaque, nt)) != APR_SUCCESS) {
+            TCN_ERROR_WRAP(ss);
+            return -(jint)ss;
+        }
+    }
     ss = (*s->net->recv)(s->opaque, s->jrbbuff + offset, &nbytes);
+    if (pt != nt) {
+        if ((ss = (*s->net->timeout_set)(s->opaque, pt)) != APR_SUCCESS) {
+            TCN_ERROR_WRAP(ss);
+            return -(jint)ss;
+        }
+    }
+
 #ifdef TCN_DO_STATISTICS
     if (ss == APR_SUCCESS) {
         sp_max_recv = TCN_MAX(sp_max_recv, nbytes);
@@ -1018,7 +1065,7 @@
     if (!sock) {
         tcn_ThrowAPRException(e, APR_ENOTSOCK);
         return APR_ENOTSOCK;
-    }    
+    }
     return (jint)(*s->net->timeout_set)(s->opaque, J2T(timeout));
 }
 
@@ -1031,7 +1078,7 @@
     if (!sock) {
         tcn_ThrowAPRException(e, APR_ENOTSOCK);
         return 0;
-    }    
+    }
     TCN_ASSERT(s->opaque != NULL);
 
     TCN_THROW_IF_ERR((*s->net->timeout_get)(s->opaque, &timeout), timeout);



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


Mime
View raw message