]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: conn-stream: Release a CS when both app and endp are detached
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 Jan 2022 07:44:58 +0000 (08:44 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 24 Feb 2022 10:00:03 +0000 (11:00 +0100)
cs_detach_app() function is added to detach an app from a conn-stream. And
now, both cs_detach_app() and cs_detach_endp() release the conn-stream when
both the app and the endpoint are detached.

include/haproxy/conn_stream.h
src/conn_stream.c

index 5be833dbca6fd547801e92213ba4d113d7c35995..fa0959c6d89f6c4797f6e9e5a8fa18fedbc48f05 100644 (file)
@@ -39,6 +39,7 @@ void cs_free(struct conn_stream *cs);
 void cs_attach_endp(struct conn_stream *cs, enum obj_type *endp, void *ctx);
 int cs_attach_app(struct conn_stream *cs, enum obj_type *app);
 void cs_detach_endp(struct conn_stream *cs);
+void cs_detach_app(struct conn_stream *cs);
 
 /*
  * Initializes all required fields for a new conn_strema.
index 0c7bf9b423a5930afcf533439da420bd6a663e65..f0b06c65bc783589e298622a2c1483a1470eff82 100644 (file)
@@ -133,11 +133,27 @@ void cs_detach_endp(struct conn_stream *cs)
                appctx_free(appctx);
        }
 
-       /* Rest CS */
+       /* FIXME: Rest CS for now but must be reviewed. CS flags are only
+        *        connection related for now but this will evolved
+        */
        cs->flags = CS_FL_NONE;
        cs->end = NULL;
        cs->ctx = NULL;
        if (cs->si)
                cs->si->ops = &si_embedded_ops;
        cs->data_cb = NULL;
+
+       if (cs->app == NULL)
+               cs_free(cs);
+}
+
+void cs_detach_app(struct conn_stream *cs)
+{
+       si_free(cs->si);
+       cs->app = NULL;
+       cs->si  = NULL;
+       cs->data_cb = NULL;
+
+       if (cs->end == NULL)
+               cs_free(cs);
 }