#define STAT_CLI_O_SET 10 /* set entries in tables */
#define STAT_CLI_O_STAT 11 /* dump stats */
+/* HTTP stats : applet.st0 */
+enum {
+ STAT_HTTP_DONE = 0, /* finished */
+ STAT_HTTP_DUMP, /* dumping stats */
+};
+
/* HTML form to limit output scope */
#define STAT_SCOPE_TXT_MAXLEN 20 /* max len for scope substring */
#define STAT_SCOPE_INPUT_NAME "scope" /* pattern form scope name <input> in html form */
/* This I/O handler runs as an applet embedded in a stream interface. It is
* used to send HTTP stats over a TCP socket. The mechanism is very simple.
- * si->applet.st0 becomes non-zero once the transfer is finished. The handler
+ * si->applet.st0 contains the operation in progress (dump, done). The handler
* automatically unregisters itself once transfer is complete.
*/
static void http_stats_io_handler(struct stream_interface *si)
/* check that the output is not closed */
if (res->flags & (CF_SHUTW|CF_SHUTW_NOW))
- si->applet.st0 = 1;
+ si->applet.st0 = STAT_HTTP_DONE;
- if (!si->applet.st0) {
+ switch (si->applet.st0) {
+ case STAT_HTTP_DUMP:
if (stats_dump_stat_to_buffer(si, s->be->uri_auth)) {
- si->applet.st0 = 1;
+ si->applet.st0 = STAT_HTTP_DONE;
si_shutw(si);
}
+ break;
}
if ((res->flags & CF_SHUTR) && (si->state == SI_ST_EST))
si_shutw(si);
- if ((req->flags & CF_SHUTW) && (si->state == SI_ST_EST) && si->applet.st0) {
- si_shutr(si);
- res->flags |= CF_READ_NULL;
+ if (si->applet.st0 == STAT_HTTP_DONE) {
+ if ((req->flags & CF_SHUTW) && (si->state == SI_ST_EST)) {
+ si_shutr(si);
+ res->flags |= CF_READ_NULL;
+ }
}
/* update all other flags and resync with the other side */
s->task->nice = -32; /* small boost for HTTP statistics */
stream_int_register_handler(s->rep->prod, &http_stats_applet);
s->target = s->rep->prod->conn->target; // for logging only
- s->rep->prod->applet.st0 = s->rep->prod->applet.st1 = s->rep->prod->applet.st2 = 0;
+ s->rep->prod->applet.st0 = STAT_HTTP_DUMP;
+ s->rep->prod->applet.st1 = s->rep->prod->applet.st2 = 0;
req->analysers = 0;
return 1;
}