From: Christopher Faulet Date: Tue, 21 Jan 2025 06:41:33 +0000 (+0100) Subject: MINOR: tevt/applet: Add limited support for termination event logs for applets X-Git-Tag: v3.2-dev5~52 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=eb2f1a4ba4f6717bcd9b9f7ada91d9d9596d1002;p=thirdparty%2Fhaproxy.git MINOR: tevt/applet: Add limited support for termination event logs for applets There is no termination events log for applet but events for the SE location are filled when the endpoint is an applet. Most of them relies on the new applet API. Only few events are reported for legacy applets. --- diff --git a/src/applet.c b/src/applet.c index ee1732ff4..7bd5f0460 100644 --- a/src/applet.c +++ b/src/applet.c @@ -558,6 +558,11 @@ size_t appctx_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, unsig se_fl_set(appctx->sedesc, SE_FL_ERROR); TRACE_STATE("report ERROR to SE", APPLET_EV_RECV|APPLET_EV_BLK, appctx); } + + if (applet_fl_test(appctx, APPCTX_FL_ERROR)) + se_report_term_evt(appctx->sedesc, !applet_fl_test(appctx, APPCTX_FL_EOI) ? se_tevt_type_truncated_rcv_err : se_tevt_type_rcv_err); + else if (applet_fl_test(appctx, APPCTX_FL_EOS)) + se_report_term_evt(appctx->sedesc, !applet_fl_test(appctx, APPCTX_FL_EOI) ? se_tevt_type_truncated_eos : se_tevt_type_eos); } end: @@ -632,6 +637,9 @@ size_t appctx_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, unsig ret = appctx->applet->snd_buf(appctx, buf, count, flags); + if (applet_fl_test(appctx, (APPCTX_FL_ERROR|APPCTX_FL_ERR_PENDING))) + se_report_term_evt(appctx->sedesc, se_tevt_type_snd_err); + end: if (applet_fl_test(appctx, (APPCTX_FL_ERROR|APPCTX_FL_ERR_PENDING))) { BUG_ON((applet_fl_get(appctx) & (APPCTX_FL_EOS|APPCTX_FL_ERROR|APPCTX_FL_ERR_PENDING)) == (APPCTX_FL_EOS|APPCTX_FL_ERR_PENDING)); @@ -712,6 +720,11 @@ int appctx_fastfwd(struct stconn *sc, unsigned int count, unsigned int flags) /* else */ /* applet_have_more_data(appctx); */ + if (applet_fl_test(appctx, APPCTX_FL_ERROR)) + se_report_term_evt(appctx->sedesc, !applet_fl_test(appctx, APPCTX_FL_EOI) ? se_tevt_type_truncated_rcv_err : se_tevt_type_rcv_err); + else if (applet_fl_test(appctx, APPCTX_FL_EOS)) + se_report_term_evt(appctx->sedesc, !applet_fl_test(appctx, APPCTX_FL_EOI) ? se_tevt_type_truncated_eos : se_tevt_type_eos); + if (se_done_ff(sdo) != 0 || !(sdo->iobuf.flags & (IOBUF_FL_FF_BLOCKED|IOBUF_FL_FF_WANT_ROOM))) { /* Something was forwarding or the consumer states it is not * blocked anyore, don't reclaim more room */ diff --git a/src/stconn.c b/src/stconn.c index 729886ddf..ddb56eff8 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -969,6 +969,7 @@ static void sc_app_shut_applet(struct stconn *sc) sc->flags |= SC_FL_SHUT_DONE; oc->flags |= CF_WRITE_EVENT; sc_set_hcto(sc); + sc_report_term_evt(sc, strm_tevt_type_shutw); /* on shutw we always wake the applet up */ appctx_wakeup(__sc_appctx(sc)); @@ -1946,6 +1947,7 @@ static void sc_applet_eos(struct stconn *sc) sc->flags |= SC_FL_EOS; ic->flags |= CF_READ_EVENT; sc_ep_report_read_activity(sc); + sc_report_term_evt(sc, (sc->flags & SC_FL_EOI ? strm_tevt_type_eos: strm_tevt_type_truncated_eos)); /* Note: on abort, we don't call the applet */