You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ro...@apache.org on 2006/01/24 07:21:11 UTC

svn commit: r371840 - /httpd/httpd/branches/fcgi-proxy-dev/modules/proxy/mod_proxy_fcgi.c

Author: rooneg
Date: Mon Jan 23 22:21:09 2006
New Revision: 371840

URL: http://svn.apache.org/viewcvs?rev=371840&view=rev
Log:
Clean up the end-of-headers detection code a bit.  I'm still getting some
strange problems with really large numbers of headers, but I'm starting to
suspect that it's a problem with my FastCGI lib, not this module, and this
at least makes things shorter and a bit easier to read, along with fixing
one bug.

* modules/proxy/mod_proxy_fcgi.c
  (handle_headers): Get rid of some cases that were not strictly needed.
   Insert a case that was missed that screwed things up when there were
   more than one header.
  (dispatch): Move the 'done with headers' code into the preceding block,
   add a note about a case that needs to be investigated.

Modified:
    httpd/httpd/branches/fcgi-proxy-dev/modules/proxy/mod_proxy_fcgi.c

Modified: httpd/httpd/branches/fcgi-proxy-dev/modules/proxy/mod_proxy_fcgi.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/branches/fcgi-proxy-dev/modules/proxy/mod_proxy_fcgi.c?rev=371840&r1=371839&r2=371840&view=diff
==============================================================================
--- httpd/httpd/branches/fcgi-proxy-dev/modules/proxy/mod_proxy_fcgi.c (original)
+++ httpd/httpd/branches/fcgi-proxy-dev/modules/proxy/mod_proxy_fcgi.c Mon Jan 23 22:21:09 2006
@@ -354,25 +354,17 @@
     while (*itr) {
         if (*itr == '\r') {
             switch (*state) {
-                case HDR_STATE_READING_HEADERS:
-                    *state = HDR_STATE_GOT_CR;
-                    break;
-
                 case HDR_STATE_GOT_CRLF:
                     *state = HDR_STATE_GOT_CRLFCR;
                     break;
 
                 default:
-                    *state = HDR_STATE_READING_HEADERS;
+                    *state = HDR_STATE_GOT_CR;
                     break;
             }
         }
         else if (*itr == '\n') {
             switch (*state) {
-                 case HDR_STATE_READING_HEADERS:
-                     *state = HDR_STATE_GOT_LF;
-                     break;
-
                  case HDR_STATE_GOT_LF:
                      *state = HDR_STATE_DONE_WITH_HEADERS;
                      break;
@@ -386,10 +378,13 @@
                      break;
 
                  default:
-                     *state = HDR_STATE_READING_HEADERS;
+                     *state = HDR_STATE_GOT_LF;
                      break;
             }
         }
+        else {
+            *state = HDR_STATE_READING_HEADERS;
+        }
 
         if (*state == HDR_STATE_DONE_WITH_HEADERS)
             break;
@@ -669,26 +664,26 @@
 
                         if (st == 1) {
                             seen_end_of_headers = 1;
+
+                            rv = ap_pass_brigade(r->output_filters, ob);
+                            if (rv != APR_SUCCESS) {
+                                break;
+                            }
+
+                            apr_brigade_cleanup(ob);
+
+                            apr_pool_clear(pfb->scratch_pool);
                         }
                         else if (st == -1) {
                             rv = APR_EINVAL;
                             break;
                         }
-                    }
-
-                    if (seen_end_of_headers) {
-                        rv = ap_pass_brigade(r->output_filters, ob);
-                        if (rv != APR_SUCCESS) {
-                            break;
+                        else {
+                            /* We're still looking for the end of the
+                             * headers, so this part of the data will need
+                             * to persist. */
+                            apr_bucket_setaside(b, pfb->scratch_pool);
                         }
-
-                        apr_brigade_cleanup(ob);
-
-                        apr_pool_clear(pfb->scratch_pool);
-                    } else {
-                        /* We're still looking for the end of the headers,
-                         * so this part of the data will need to persist. */
-                        apr_bucket_setaside(b, pfb->scratch_pool);
                     }
 
                     /* If we didn't read all the data go back and get the
@@ -698,6 +693,8 @@
                         goto recv_again;
                     }
                 } else {
+                    /* XXX what if we haven't seen end of the headers yet? */
+
                     b = apr_bucket_eos_create(c->bucket_alloc);
 
                     APR_BRIGADE_INSERT_TAIL(ob, b);