]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] slightly rebalance stats_dump_{raw,http}
authorWilly Tarreau <w@1wt.eu>
Sun, 7 Dec 2008 17:30:00 +0000 (18:30 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 7 Dec 2008 17:30:00 +0000 (18:30 +0100)
Both should process the response buffer equally. They now both
clear the hijack bit once done, and both receive a pointer to
the response buffer in their arguments.

include/proto/dumpstats.h
src/dumpstats.c
src/proto_http.c

index bc6bdad37dabbb573db41eec884938ed65934b25..8fd3ccb50937d81b5bcdf2d24d3db0f9cdd18b54 100644 (file)
@@ -44,9 +44,9 @@
 #define STATS_ST_REP   2
 #define STATS_ST_CLOSE 3
 
-int stats_dump_raw(struct session *s, struct uri_auth *uri);
+int stats_dump_raw(struct session *s, struct buffer *rep, struct uri_auth *uri);
 void stats_dump_raw_to_buffer(struct session *s, struct buffer *req);
-int stats_dump_http(struct session *s, struct uri_auth *uri);
+int stats_dump_http(struct session *s, struct buffer *rep, struct uri_auth *uri);
 int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri);
 
 
index 590edbe7ee2c0566655e91a3eb741e9cc8723402..30cb0edf3b8c1f43fb9b7279682ba8d56408a015 100644 (file)
@@ -182,10 +182,10 @@ int print_csv_header(struct chunk *msg, int size)
  * <uri>. s->data_ctx must have been zeroed first, and the flags properly set.
  * It returns 0 if it had to stop writing data and an I/O is needed, 1 if the
  * dump is finished and the session must be closed, or -1 in case of any error.
+ * It automatically clears the HIJACK bit from the response buffer.
  */
-int stats_dump_raw(struct session *s, struct uri_auth *uri)
+int stats_dump_raw(struct session *s, struct buffer *rep, struct uri_auth *uri)
 {
-       struct buffer *rep = s->rep;
        struct proxy *px;
        struct chunk msg;
        unsigned int up;
@@ -276,13 +276,15 @@ int stats_dump_raw(struct session *s, struct uri_auth *uri)
 
        case DATA_ST_END:
                s->data_state = DATA_ST_FIN;
-               return 1;
+               /* fall through */
 
        case DATA_ST_FIN:
+               buffer_stop_hijack(rep);
                return 1;
 
        default:
                /* unknown state ! */
+               buffer_stop_hijack(rep);
                return -1;
        }
 }
@@ -292,15 +294,13 @@ int stats_dump_raw(struct session *s, struct uri_auth *uri)
  * calls stats_dump_raw(), and releases the buffer's hijack bit when the dump
  * is finished.
  */
-void stats_dump_raw_to_buffer(struct session *s, struct buffer *req)
+void stats_dump_raw_to_buffer(struct session *s, struct buffer *rep)
 {
        if (s->ana_state != STATS_ST_REP)
                return;
 
-       if (stats_dump_raw(s, NULL) != 0) {
-               buffer_stop_hijack(s->rep);
+       if (stats_dump_raw(s, rep, NULL) != 0)
                s->ana_state = STATS_ST_CLOSE;
-       }
        return;
 }
 
@@ -315,9 +315,8 @@ void stats_dump_raw_to_buffer(struct session *s, struct buffer *req)
  * 1 if the dump is finished and the session must be closed, or -1 in case of
  * any error.
  */
-int stats_dump_http(struct session *s, struct uri_auth *uri)
+int stats_dump_http(struct session *s, struct buffer *rep, struct uri_auth *uri)
 {
-       struct buffer *rep = s->rep;
        struct proxy *px;
        struct chunk msg;
        unsigned int up;
index 092c730abc75c8c0b704304b9e7e702dde7c2c67..f931da4f9050acc321d8aec4291556c0970a7cd4 100644 (file)
@@ -2999,7 +2999,7 @@ void produce_content(struct session *s, struct buffer *rep)
        }
        else if (s->data_source == DATA_SRC_STATS) {
                /* dump server statistics */
-               int ret = stats_dump_http(s, s->be->uri_auth);
+               int ret = stats_dump_http(s, rep, s->be->uri_auth);
                if (ret >= 0)
                        return;
                /* -1 indicates an error */