]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: promex: Use the sedesc to report and detect end of processing
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 31 Mar 2023 09:29:54 +0000 (11:29 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Apr 2023 06:57:06 +0000 (08:57 +0200)
Just like for other applets, we now use the SE descriptor instead of the
channel to report error and end-of-stream.

addons/promex/service-prometheus.c

index bc88a7b0939392325200008d94b1026f0821308e..d03399c086924187dccae7edeebe38aa971aa73d 100644 (file)
@@ -1486,7 +1486,6 @@ static int promex_parse_uri(struct appctx *appctx, struct stconn *sc)
        memcpy(res->buf.area, b_head(err), b_data(err));
        res_htx = htx_from_buf(&res->buf);
        channel_add_input(res, res_htx->data);
-       appctx->st0 = PROMEX_ST_END;
        return -1;
 }
 
@@ -1539,7 +1538,8 @@ static void promex_appctx_handle_io(struct appctx *appctx)
        int ret;
 
        res_htx = htx_from_buf(&res->buf);
-       if (unlikely(sc->state == SC_ST_DIS || sc->state == SC_ST_CLO))
+
+       if (unlikely(se_fl_test(appctx->sedesc, (SE_FL_EOS|SE_FL_ERROR|SE_FL_SHR|SE_FL_SHW))))
                goto out;
 
        /* Check if the input buffer is available. */
@@ -1596,9 +1596,7 @@ static void promex_appctx_handle_io(struct appctx *appctx)
                        __fallthrough;
 
                case PROMEX_ST_END:
-                       if (!(res->flags & CF_SHUTR)) {
-                               sc_shutr(sc);
-                       }
+                       se_fl_set(appctx->sedesc, SE_FL_EOS);
        }
 
   out:
@@ -1612,8 +1610,7 @@ static void promex_appctx_handle_io(struct appctx *appctx)
        return;
 
   error:
-       sc_shutr(sc);
-       sc_shutw(sc);
+       se_fl_set(appctx->sedesc, SE_FL_ERROR);
        goto out;
 }