]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-fcgi: make sure any stream always has an endpoint
authorWilly Tarreau <w@1wt.eu>
Tue, 10 May 2022 13:02:32 +0000 (15:02 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 13 May 2022 12:28:48 +0000 (14:28 +0200)
The principle that each mux stream should have an endpoint is not
guaranteed for closed streams that map to the dummy static streams.
Let's have a dummy endpoint for use with such streams. It only has
the DETACHED flag and a NULL conn_stream, and is referenced by all
the closed streams so that we can afford not to test strm->endp when
trying to access the flags or the CS.

src/mux_fcgi.c

index 2afa2ff7ffa2a40917ed66d3491bd85c41c644a6..ab3d013d4de601466bfe16b53bd1186dc2b28667 100644 (file)
@@ -371,9 +371,16 @@ static void fcgi_strm_notify_send(struct fcgi_strm *fstrm);
 static void fcgi_strm_alert(struct fcgi_strm *fstrm);
 static int fcgi_strm_send_abort(struct fcgi_conn *fconn, struct fcgi_strm *fstrm);
 
+/* a dummy closed endpoint */
+static const struct cs_endpoint closed_ep = {
+       . cs       = NULL,
+       .flags     = CS_EP_DETACHED,
+};
+
 /* a dmumy management stream */
 static const struct fcgi_strm *fcgi_mgmt_stream = &(const struct fcgi_strm){
        .cs        = NULL,
+       .endp      = (struct cs_endpoint*)&closed_ep,
        .fconn     = NULL,
        .state     = FCGI_SS_CLOSED,
        .flags     = FCGI_SF_NONE,
@@ -383,6 +390,7 @@ static const struct fcgi_strm *fcgi_mgmt_stream = &(const struct fcgi_strm){
 /* and a dummy idle stream for use with any unknown stream */
 static const struct fcgi_strm *fcgi_unknown_stream = &(const struct fcgi_strm){
        .cs        = NULL,
+       .endp      = (struct cs_endpoint*)&closed_ep,
        .fconn     = NULL,
        .state     = FCGI_SS_IDLE,
        .flags     = FCGI_SF_NONE,