From: Christopher Faulet Date: Fri, 31 Mar 2023 09:21:06 +0000 (+0200) Subject: MEDIUM: peers: Use the sedesc to report and detect end of processing X-Git-Tag: v2.8-dev7~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d949010bcfec59c66c35643132bdce9641cb4ec;p=thirdparty%2Fhaproxy.git MEDIUM: peers: Use the sedesc to report and detect end of processing Just like for other applets, we now use the SE descriptor instead of the channel to report error and end-of-stream. We must just be sure to consume request data when we are waiting the applet to be released. --- diff --git a/src/peers.c b/src/peers.c index fab92eec25..725f704c23 100644 --- a/src/peers.c +++ b/src/peers.c @@ -2408,7 +2408,7 @@ static inline int peer_recv_msg(struct appctx *appctx, char *msg_head, size_t ms return 1; incomplete: - if (reql < 0 || (sc_oc(sc)->flags & (CF_SHUTW|CF_SHUTW_NOW))) { + if (reql < 0) { /* there was an error or the message was truncated */ appctx->st0 = PEER_SESS_ST_END; return -1; @@ -2923,6 +2923,11 @@ static void peer_io_handler(struct appctx *appctx) unsigned int maj_ver, min_ver; int prev_state; + if (unlikely(se_fl_test(appctx->sedesc, (SE_FL_EOS|SE_FL_ERROR|SE_FL_SHR|SE_FL_SHW)))) { + co_skip(sc_oc(sc), co_data(sc_oc(sc))); + goto out; + } + /* Check if the input buffer is available. */ if (sc_ib(sc)->size == 0) { sc_need_room(sc); @@ -3191,8 +3196,8 @@ send_msgs: HA_SPIN_UNLOCK(PEER_LOCK, &curpeer->lock); curpeer = NULL; } - sc_shutw(sc); - sc_shutr(sc); + se_fl_set(appctx->sedesc, SE_FL_EOS|SE_FL_EOI); + co_skip(sc_oc(sc), co_data(sc_oc(sc))); goto out; } }