]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] stats_dump_sess_to_buffer: use buffer_feed_chunk()
authorWilly Tarreau <w@1wt.eu>
Sat, 3 Oct 2009 21:55:14 +0000 (23:55 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 4 Oct 2009 09:00:11 +0000 (11:00 +0200)
same as previous patch for this function.

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

index 4dd9e3488feeae33b87e806c722d328e2db4c02e..990c620d56a5c3597e1dfebd8331e8de2ea4bbf8 100644 (file)
@@ -50,7 +50,7 @@ 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 buffer *rep, struct uri_auth *uri);
 int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri);
-void stats_dump_sess_to_buffer(struct session *s, struct buffer *rep);
+int stats_dump_sess_to_buffer(struct session *s, struct buffer *rep);
 int stats_dump_errors_to_buffer(struct session *s, struct buffer *rep);
 
 
index 6c8c97bba4df3ebdfec5b9e6ace52668d9e40604..d39bbcd3d7823c4d1ff78f3eaefd621b402bd798 100644 (file)
@@ -423,9 +423,7 @@ void stats_io_handler(struct stream_interface *si)
                                        si->st0 = 1; // end of command, send prompt
                                break;
                        case 4: /* sessions dump */
-                               stats_dump_sess_to_buffer(s, res);
-                               si->ib->flags |= BF_READ_PARTIAL; /* remove this once we use buffer_feed */
-                               if (s->ana_state == STATS_ST_CLOSE)
+                               if (stats_dump_sess_to_buffer(s, res))
                                        si->st0 = 1; // end of command, send prompt
                                break;
                        case 5: /* errors dump */
@@ -1524,9 +1522,9 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri)
  * It dumps the sessions states onto the output buffer <rep>.
  * Expects to be called with client socket shut down on input.
  * s->data_ctx must have been zeroed first, and the flags properly set.
- * It automatically clears the HIJACK bit from the response buffer.
+ * It returns 0 as long as it does not complete, non-zero upon completion.
  */
-void stats_dump_sess_to_buffer(struct session *s, struct buffer *rep)
+int stats_dump_sess_to_buffer(struct session *s, struct buffer *rep)
 {
        struct chunk msg;
 
@@ -1540,15 +1538,9 @@ void stats_dump_sess_to_buffer(struct session *s, struct buffer *rep)
                                LIST_INIT(&s->data_ctx.sess.bref.users);
                        }
                }
-               s->data_state = DATA_ST_FIN;
-               buffer_stop_hijack(rep);
-               s->ana_state = STATS_ST_CLOSE;
-               return;
+               return 1;
        }
 
-       if (s->ana_state != STATS_ST_REP)
-               return;
-
        chunk_init(&msg, trash, sizeof(trash));
 
        switch (s->data_state) {
@@ -1695,12 +1687,12 @@ void stats_dump_sess_to_buffer(struct session *s, struct buffer *rep)
 
                        chunk_printf(&msg, "\n");
 
-                       if (buffer_write_chunk(rep, &msg) >= 0) {
+                       if (buffer_feed_chunk(rep, &msg) >= 0) {
                                /* let's try again later from this session. We add ourselves into
                                 * this session's users so that it can remove us upon termination.
                                 */
                                LIST_ADDQ(&curr_sess->back_refs, &s->data_ctx.sess.bref.users);
-                               return;
+                               return 0;
                        }
 
                        s->data_ctx.sess.bref.ref = curr_sess->list.n;
@@ -1710,9 +1702,7 @@ void stats_dump_sess_to_buffer(struct session *s, struct buffer *rep)
 
        default:
                s->data_state = DATA_ST_FIN;
-               buffer_stop_hijack(rep);
-               s->ana_state = STATS_ST_CLOSE;
-               return;
+               return 1;
        }
 }