]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] http: dispatch and http_proxy modes were broken for a long time
authorWilly Tarreau <w@1wt.eu>
Thu, 20 May 2010 09:49:03 +0000 (11:49 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 23 May 2010 06:56:02 +0000 (08:56 +0200)
Both dispatch and http_proxy modes were broken since 1.4-dev5 when
the adjustment of server health based on response codes was introduced.
In fact, in these modes, s->srv == NULL. The result is a plain segfault.
It should have been noted critical, but the fact that it remained 6
months without being noticed indicates that almost nobody uses these
modes anymore. Also, the crash is immediate upon first request.

Further versions should not be affected anymore since it's planned to
have a dummy server instead of these annoying NULL pointers.

src/proto_http.c

index 0209391b178be9b93fbd53800a4bdcb0133f986e..3c5cf73bbb71a9cb9cd8e5c6ea073df9f4cf0a3b 100644 (file)
@@ -4493,7 +4493,8 @@ int http_wait_for_response(struct session *s, struct buffer *rep, int an_bit)
        n = msg->sol[msg->sl.st.c] - '0';
        if (n < 1 || n > 5)
                n = 0;
-       s->srv->counters.p.http.rsp[n]++;
+       if (s->srv)
+               s->srv->counters.p.http.rsp[n]++;
 
        /* check if the response is HTTP/1.1 or above */
        if ((msg->sl.st.v_l == 8) &&
@@ -4514,10 +4515,12 @@ int http_wait_for_response(struct session *s, struct buffer *rep, int an_bit)
         * and 505 are triggered on demand by client request, so we must not
         * count them as server failures.
         */
-       if (txn->status >= 100 && (txn->status < 500 || txn->status == 501 || txn->status == 505))
-               health_adjust(s->srv, HANA_STATUS_HTTP_OK);
-       else
-               health_adjust(s->srv, HANA_STATUS_HTTP_STS);
+       if (s->srv) {
+               if (txn->status >= 100 && (txn->status < 500 || txn->status == 501 || txn->status == 505))
+                       health_adjust(s->srv, HANA_STATUS_HTTP_OK);
+               else
+                       health_adjust(s->srv, HANA_STATUS_HTTP_STS);
+       }
 
        /*
         * 2: check for cacheability.