]> granicus.if.org Git - apache/commitdiff
http_filter():
authorJeff Trawick <trawick@apache.org>
Tue, 17 Oct 2000 15:28:57 +0000 (15:28 +0000)
committerJeff Trawick <trawick@apache.org>
Tue, 17 Oct 2000 15:28:57 +0000 (15:28 +0000)
  when delivering body bytes, only deliver one block of data (however
  much is returned by bucket read) instead of delivering the entire
  body at once; this gets painful with a large body

  make a note of an issue with the blocking state of the socket;
  currently, the socket is non-blocking, but when reading body bytes
  we should feel free to wait for body bytes until a timeout occurs;

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86628 13f79535-47bb-0310-9956-ffa450edef68

modules/http/http_protocol.c

index 4124668c3c1cfd9092a51872a0588b0e43c6fe6e..0911e7543a6ebc26a5aabdbba08cb10b31e09afb 100644 (file)
@@ -1000,32 +1000,39 @@ apr_status_t http_filter(ap_filter_t *f, ap_bucket_brigade *b, apr_ssize_t lengt
         }
     }
 
-    if (f->c->remain > 0) {
-        const char *ignore;
-
+    if (f->c->remain) {
         e = AP_BRIGADE_FIRST(b);
         while (e != AP_BRIGADE_SENTINEL(b)) {
-            ap_bucket_read(e, &ignore, &len, 0);
-            if (f->c->remain < len) {
-                break;
+            const char *ignore;
+
+            if ((rv = ap_bucket_read(e, &ignore, &len, 0)) != APR_SUCCESS) {
+                /* probably APR_IS_EAGAIN(rv); socket state isn't correct;
+                 * remove log once we get this squared away */
+                ap_log_error(APLOG_MARK, APLOG_ERR, rv, f->c->base_server, 
+                             "ap_bucket_read");
+                return rv;
             }
-            f->c->remain -= len;
-            e = AP_BUCKET_NEXT(e);
-        }
-        if (e != AP_BRIGADE_SENTINEL(b)) {
-            if (f->c->remain < len) {
-                ap_bucket_split(e, f->c->remain);
-                f->c->remain = 0;
+
+            if (len) {
+                if (f->c->remain < len) {
+                    ap_bucket_split(e, f->c->remain);
+                    f->c->remain = 0;
+                }
+                else {
+                    f->c->remain -= len;
+                }
+                bb = ap_brigade_split(b, AP_BUCKET_NEXT(e));
+                ctx->b = bb;
+                break; /* once we've gotten some data, deliver it to caller */
             }
-            bb = ap_brigade_split(b, AP_BUCKET_NEXT(e));
-            ctx->b = bb;
+            e = AP_BUCKET_NEXT(e);
         }
-        else {
+        if (e == AP_BRIGADE_SENTINEL(b)) {
             ctx->b = NULL;
         }
         if (f->c->remain == 0) {
             ap_bucket *eos = ap_bucket_create_eos();
-
+                
             AP_BRIGADE_INSERT_TAIL(b, eos);
         }
         return APR_SUCCESS;