You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by pq...@apache.org on 2007/11/14 22:17:58 UTC

svn commit: r595061 - /httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c

Author: pquerna
Date: Wed Nov 14 13:17:55 2007
New Revision: 595061

URL: http://svn.apache.org/viewvc?rev=595061&view=rev
Log:
Finish the non-blocking write to the network via serf.

Modified:
    httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c

Modified: httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c?rev=595061&r1=595060&r2=595061&view=diff
==============================================================================
--- httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c (original)
+++ httpd/sandbox/amsterdam/d/modules/proxy/mod_serf.c Wed Nov 14 13:17:55 2007
@@ -568,24 +568,42 @@
     }
 
     if (c->data_in_output_filters && new_bb  == NULL) {
-        const char *buf;
-        apr_size_t len = 0;
+        do {
+            apr_status_t srv;
+            const char *buf;
+            apr_size_t len = 0;
 
-        rv = serf_bucket_read(ctx->serf_out_bucket,
-                              SERF_READ_ALL_AVAIL,
-                              &buf,
-                              &len);
+            srv = serf_bucket_read(ctx->serf_out_bucket,
+                                  SERF_READ_ALL_AVAIL,
+                                  &buf,
+                                  &len);
         
-        do { 
+            if (SERF_BUCKET_READ_ERROR(srv)) {
+                /* bad, logme */
+                return srv;
+            }
+
             /* write data to network here. */
-            apr_size_t blen = len;
-            rv = apr_socket_send(net->client_socket, buf, &blen);
-            if (blen != len) {
-                b = serf_bucket_simple_create(buf+blen, len - blen, NULL, NULL, ctx->serf_bkt_alloc);
-                serf_bucket_aggregate_prepend(ctx->serf_out_bucket, b);
+            if (len > 0) {
+                apr_size_t blen = len;
+                rv = apr_socket_send(net->client_socket, buf, &blen);
+                if (blen != len) {
+                    b = serf_bucket_simple_create(buf+blen, len - blen, NULL, NULL, ctx->serf_bkt_alloc);
+                    serf_bucket_aggregate_prepend(ctx->serf_out_bucket, b);
+                    srv = APR_SUCCESS;
+                }
+            }
+            
+            if (APR_STATUS_IS_EOF(srv)) {
+                c->data_in_output_filters = 0;
+                break;
             }
-        } while (0);
+            if (APR_STATUS_IS_EAGAIN(srv)) {
+                break;
+            }
+        } while (rv == APR_SUCCESS);
     }
+
     return APR_SUCCESS;
 }