From: Olivier Houchard Date: Sat, 10 Aug 2019 21:56:16 +0000 (+0200) Subject: BUG/MEDIUM: mux_pt: Don't call unsubscribe if we did not subscribe. X-Git-Tag: v2.1-dev2~206 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea32b0fa50aafc150a3f660cb55943fd181deab4;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: mux_pt: Don't call unsubscribe if we did not subscribe. In mux_pt_attach(), don't inconditionally call unsubscribe, and only do so if we were subscribed. The idea was that at this point we would always be subscribed, as for the mux_pt attach would only be called after at least one request, after which the mux_pt would have subscribed, but this is wrong. We can also be called if for some reason the connection failed before the xprt was created. And with no xprt, attempting to call unsubscribe will probably lead to a crash. This should be backported to 2.0. --- diff --git a/src/mux_pt.c b/src/mux_pt.c index 0119cb9c25..a86cbefd92 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -146,7 +146,8 @@ static struct conn_stream *mux_pt_attach(struct connection *conn, struct session struct conn_stream *cs; struct mux_pt_ctx *ctx = conn->ctx; - conn->xprt->unsubscribe(ctx->conn, conn->xprt_ctx, SUB_RETRY_RECV, &ctx->wait_event); + if (ctx->wait_event.events) + conn->xprt->unsubscribe(ctx->conn, conn->xprt_ctx, SUB_RETRY_RECV, &ctx->wait_event); cs = cs_new(conn); if (!cs) goto fail;