]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tevt/applet: Add limited support for termination event logs for applets
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 21 Jan 2025 06:41:33 +0000 (07:41 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 31 Jan 2025 09:41:50 +0000 (10:41 +0100)
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.

src/applet.c
src/stconn.c

index ee1732ff46af14b687d894f8c71df9458abcaf48..7bd5f04603c90dbcac7944c5a12da583082358cb 100644 (file)
@@ -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 */
index 729886ddfb324c706da706792d0567e769a7be15..ddb56eff88ab728ab7a282392d01e8d255adfcbd 100644 (file)
@@ -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 */