httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r307371 - /httpd/httpd/branches/async-dev/server/core_filters.c
Date Sun, 09 Oct 2005 05:43:09 GMT
Author: brianp
Date: Sat Oct  8 22:43:08 2005
New Revision: 307371

URL: http://svn.apache.org/viewcvs?rev=307371&view=rev
Log:
cleaned up the timeout management in ap_core_output_filter()

Modified:
    httpd/httpd/branches/async-dev/server/core_filters.c

Modified: httpd/httpd/branches/async-dev/server/core_filters.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/async-dev/server/core_filters.c?rev=307371&r1=307370&r2=307371&view=diff
==============================================================================
--- httpd/httpd/branches/async-dev/server/core_filters.c (original)
+++ httpd/httpd/branches/async-dev/server/core_filters.c Sat Oct  8 22:43:08 2005
@@ -348,8 +348,17 @@
     apr_size_t bytes_in_brigade, non_file_bytes_in_brigade;
        
     if (ctx == NULL) {
+        apr_status_t rv;
         ctx = apr_pcalloc(c->pool, sizeof(*ctx));
         net->out_ctx = (core_output_filter_ctx_t *)ctx;
+        rv = apr_socket_timeout_set(net->client_socket, 0);
+        if (rv != APR_SUCCESS) {
+            return rv;
+        }
+        rv = apr_socket_opt_set(net->client_socket, APR_SO_NONBLOCK, 1);
+        if (rv != APR_SUCCESS) {
+            return rv;
+        }
     }
 
     if (new_bb != NULL) {
@@ -501,19 +510,9 @@
 {
     apr_bucket *bucket, *next;
     apr_status_t rv;
-    apr_interval_time_t old_timeout;
     struct iovec vec[MAX_IOVEC_TO_WRITE];
     apr_size_t nvec = 0;
 
-    rv = apr_socket_timeout_get(s, &old_timeout);
-    if (rv != APR_SUCCESS) {
-        return rv;
-    }
-    rv = apr_socket_timeout_set(s, 0);
-    if (rv != APR_SUCCESS) {
-        return rv;
-    }
-
     remove_empty_buckets(bb);
 
     for (bucket = APR_BRIGADE_FIRST(bb);
@@ -539,13 +538,11 @@
                 nvec = 0;
                 if (rv != APR_SUCCESS) {
                     (void)apr_socket_opt_set(s, APR_TCP_NOPUSH, 0);
-                    (void)apr_socket_timeout_set(s, old_timeout);
                     return rv;
                 }
                 rv = sendfile_nonblocking(s, bb, bytes_written, c);
                 (void)apr_socket_opt_set(s, APR_TCP_NOPUSH, 0);
                 if (rv != APR_SUCCESS) {
-                    (void)apr_socket_timeout_set(s, old_timeout);
                     return rv;
                 }
             }
@@ -556,7 +553,6 @@
             apr_size_t length;
             rv = apr_bucket_read(bucket, &data, &length, APR_BLOCK_READ);
             if (rv != APR_SUCCESS) {
-                (void)apr_socket_timeout_set(s, old_timeout);
                 return rv;
             }
             /* reading may have split the bucket, so recompute next: */
@@ -568,7 +564,6 @@
                 rv = writev_nonblocking(s, vec, nvec, bb, bytes_written, c);
                 nvec = 0;
                 if (rv != APR_SUCCESS) {
-                    (void)apr_socket_timeout_set(s, old_timeout);
                     return rv;
                 }
             }
@@ -578,14 +573,12 @@
     if (nvec > 0) {
         rv = writev_nonblocking(s, vec, nvec, bb, bytes_written, c);
         if (rv != APR_SUCCESS) {
-            (void)apr_socket_timeout_set(s, old_timeout);
             return rv;
         }
     }
 
     remove_empty_buckets(bb);
 
-    (void)apr_socket_timeout_set(s, old_timeout);
     return APR_SUCCESS;
 }
 
@@ -604,21 +597,35 @@
                                           apr_size_t *bytes_written,
                                           conn_rec *c)
 {
+    apr_status_t rv, arv;
+
+    rv = apr_socket_timeout_set(s, c->base_server->timeout);
+    if (rv != APR_SUCCESS) {
+        return rv;
+    }
+
+    rv = APR_SUCCESS;
     while (!APR_BRIGADE_EMPTY(bb)) {
-        apr_status_t rv = send_brigade_nonblocking(s, bb, bytes_written, c);
+        rv = send_brigade_nonblocking(s, bb, bytes_written, c);
         if (rv != APR_SUCCESS) {
             if (APR_STATUS_IS_EAGAIN(rv)) {
                 rv = apr_wait_for_io_or_timeout(NULL, s, 0);
                 if (rv != APR_SUCCESS) {
-                    return rv;
+                    break;
                 }
             }
             else {
-                return rv;
+                break;
             }
         }
     }
-    return APR_SUCCESS;
+    arv = apr_socket_timeout_set(s, 0);
+    if (rv != APR_SUCCESS) {
+        return rv;
+    }
+    else {
+        return arv;
+    }
 }
 
 static apr_status_t writev_nonblocking(apr_socket_t *s,



Mime
View raw message