From 7e72a8faf20a33fb042ae8c9930950496b0e0d5e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sat, 3 Oct 2009 23:55:14 +0200 Subject: [PATCH] [MINOR] stats_dump_sess_to_buffer: use buffer_feed_chunk() same as previous patch for this function. --- include/proto/dumpstats.h | 2 +- src/dumpstats.c | 24 +++++++----------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/include/proto/dumpstats.h b/include/proto/dumpstats.h index 4dd9e3488..990c620d5 100644 --- a/include/proto/dumpstats.h +++ b/include/proto/dumpstats.h @@ -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); diff --git a/src/dumpstats.c b/src/dumpstats.c index 6c8c97bba..d39bbcd3d 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -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 . * 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; } }