[nginx] svn commit: r5028 - trunk/src/http/modules

mdounin at mdounin.ru mdounin at mdounin.ru
Fri Feb 1 14:41:07 UTC 2013


Author: mdounin
Date: 2013-02-01 14:41:07 +0000 (Fri, 01 Feb 2013)
New Revision: 5028
URL: http://trac.nginx.org/nginx/changeset/5028/nginx

Log:
FastCGI: unconditional state transitions.

Checks for f->padding before state transitions make code hard to follow,
remove them and make sure we always do another loop iteration after
f->state is set to ngx_http_fastcgi_st_padding.


Modified:
   trunk/src/http/modules/ngx_http_fastcgi_module.c

Modified: trunk/src/http/modules/ngx_http_fastcgi_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_fastcgi_module.c	2013-02-01 14:40:19 UTC (rev 5027)
+++ trunk/src/http/modules/ngx_http_fastcgi_module.c	2013-02-01 14:41:07 UTC (rev 5028)
@@ -1356,11 +1356,7 @@
                 }
 
             } else {
-                if (f->padding) {
-                    f->state = ngx_http_fastcgi_st_padding;
-                } else {
-                    f->state = ngx_http_fastcgi_st_version;
-                }
+                f->state = ngx_http_fastcgi_st_padding;
             }
 
             continue;
@@ -1597,11 +1593,7 @@
         f->length -= u->buffer.pos - start;
 
         if (f->length == 0) {
-            if (f->padding) {
-                f->state = ngx_http_fastcgi_st_padding;
-            } else {
-                f->state = ngx_http_fastcgi_st_version;
-            }
+            f->state = ngx_http_fastcgi_st_padding;
         }
 
         if (rc == NGX_HTTP_PARSE_HEADER_DONE) {
@@ -1696,13 +1688,8 @@
             }
 
             if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) {
+                f->state = ngx_http_fastcgi_st_padding;
 
-                if (f->padding) {
-                    f->state = ngx_http_fastcgi_st_padding;
-                } else {
-                    f->state = ngx_http_fastcgi_st_version;
-                }
-
                 if (!flcf->keep_conn) {
                     p->upstream_done = 1;
                 }
@@ -1714,13 +1701,8 @@
             }
 
             if (f->type == NGX_HTTP_FASTCGI_END_REQUEST) {
+                f->state = ngx_http_fastcgi_st_padding;
 
-                if (f->padding) {
-                    f->state = ngx_http_fastcgi_st_padding;
-                } else {
-                    f->state = ngx_http_fastcgi_st_version;
-                }
-
                 p->upstream_done = 1;
 
                 if (flcf->keep_conn) {
@@ -1730,7 +1712,7 @@
                 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0,
                                "http fastcgi sent end request");
 
-                break;
+                continue;
             }
         }
 
@@ -1789,11 +1771,7 @@
                               m + 1 - msg, msg);
 
             } else {
-                if (f->padding) {
-                    f->state = ngx_http_fastcgi_st_padding;
-                } else {
-                    f->state = ngx_http_fastcgi_st_version;
-                }
+                f->state = ngx_http_fastcgi_st_padding;
             }
 
             continue;
@@ -1852,33 +1830,14 @@
         ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0,
                        "input buf #%d %p", b->num, b->pos);
 
-        if (f->pos + f->length < f->last) {
-
-            if (f->padding) {
-                f->state = ngx_http_fastcgi_st_padding;
-            } else {
-                f->state = ngx_http_fastcgi_st_version;
-            }
-
+        if (f->pos + f->length <= f->last) {
+            f->state = ngx_http_fastcgi_st_padding;
             f->pos += f->length;
             b->last = f->pos;
 
             continue;
         }
 
-        if (f->pos + f->length == f->last) {
-
-            if (f->padding) {
-                f->state = ngx_http_fastcgi_st_padding;
-            } else {
-                f->state = ngx_http_fastcgi_st_version;
-            }
-
-            b->last = f->last;
-
-            break;
-        }
-
         f->length -= f->last - f->pos;
 
         b->last = f->last;



More information about the nginx-devel mailing list