]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: peers: Use the sedesc to report and detect end of processing
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 31 Mar 2023 09:21:06 +0000 (11:21 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Apr 2023 06:57:05 +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. We must just be sure to consume
request data when we are waiting the applet to be released.

src/peers.c

index fab92eec25680f892b7c648d7f97c2e8cae15eaa..725f704c2336088ecfc5d0046b6dc0a6a94d03d7 100644 (file)
@@ -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;
                        }
                }