CLEANUP: conn_stream: merge cs_new_from_{mux,applet} into cs_new_from_endp()
The two functions became exact copies since there's no more special case
for the appctx owner. Let's merge them into a single one, that simplifies
the code.
diff --git a/src/conn_stream.c b/src/conn_stream.c
index c13a2a1..a37b463 100644
--- a/src/conn_stream.c
+++ b/src/conn_stream.c
@@ -156,27 +156,7 @@
* defined. It returns NULL on error. On success, the new conn-stream is
* returned. In this case, CS_EP_ORPHAN flag is removed.
*/
-struct conn_stream *cs_new_from_mux(struct cs_endpoint *endp, struct session *sess, struct buffer *input)
-{
- struct conn_stream *cs;
-
- cs = cs_new(endp);
- if (unlikely(!cs))
- return NULL;
- if (unlikely(!stream_new(sess, cs, input))) {
- pool_free(pool_head_connstream, cs);
- cs = NULL;
- }
- endp->flags &= ~CS_EP_ORPHAN;
- return cs;
-}
-
-/* Creates a new conn-stream and its associated stream from an applet. <endp>
- * must be defined. It returns NULL on error. On success, the new conn-stream is
- * returned. In this case, CS_EP_ORPHAN flag is removed. The created CS is used
- * to set the appctx owner.
- */
-struct conn_stream *cs_new_from_applet(struct cs_endpoint *endp, struct session *sess, struct buffer *input)
+struct conn_stream *cs_new_from_endp(struct cs_endpoint *endp, struct session *sess, struct buffer *input)
{
struct conn_stream *cs;
diff --git a/src/dns.c b/src/dns.c
index 35ff61a..bfd22c1 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -938,7 +938,7 @@
if (!sockaddr_alloc(&addr, &ds->dss->srv->addr, sizeof(ds->dss->srv->addr)))
goto out_free_sess;
- cs = cs_new_from_applet(appctx->endp, sess, &BUF_NULL);
+ cs = cs_new_from_endp(appctx->endp, sess, &BUF_NULL);
if (!cs) {
ha_alert("Failed to initialize stream in dns_session_create().\n");
goto out_free_addr;
diff --git a/src/flt_spoe.c b/src/flt_spoe.c
index 59db428..030ba9c 100644
--- a/src/flt_spoe.c
+++ b/src/flt_spoe.c
@@ -2026,7 +2026,7 @@
if (!sess)
goto out_free_spoe;
- cs = cs_new_from_applet(appctx->endp, sess, &BUF_NULL);
+ cs = cs_new_from_endp(appctx->endp, sess, &BUF_NULL);
if (!cs)
goto out_free_sess;
diff --git a/src/hlua.c b/src/hlua.c
index 91a9f7c..ef967a5 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -3004,7 +3004,7 @@
goto out_fail_appctx;
}
- cs = cs_new_from_applet(appctx->endp, sess, &BUF_NULL);
+ cs = cs_new_from_endp(appctx->endp, sess, &BUF_NULL);
if (!cs) {
hlua_pusherror(L, "socket: out of memory");
goto out_fail_sess;
diff --git a/src/http_client.c b/src/http_client.c
index 1efb484..4daacea 100644
--- a/src/http_client.c
+++ b/src/http_client.c
@@ -607,7 +607,7 @@
if (!sockaddr_alloc(&addr, ss_dst, sizeof(*ss_dst)))
goto out_free_sess;
- cs = cs_new_from_applet(appctx->endp, sess, &hc->req.buf);
+ cs = cs_new_from_endp(appctx->endp, sess, &hc->req.buf);
if (!cs) {
ha_alert("httpclient: Failed to initialize stream %s:%d.\n", __FUNCTION__, __LINE__);
goto out_free_addr;
diff --git a/src/mux_h1.c b/src/mux_h1.c
index e41e6ef..c5f0b03 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -726,7 +726,7 @@
if (h1s->req.flags & H1_MF_UPG_WEBSOCKET)
h1s->endp->flags |= CS_EP_WEBSOCKET;
- if (!cs_new_from_mux(h1s->endp, h1c->conn->owner, input)) {
+ if (!cs_new_from_endp(h1s->endp, h1c->conn->owner, input)) {
TRACE_ERROR("CS allocation failure", H1_EV_STRM_NEW|H1_EV_STRM_END|H1_EV_STRM_ERR, h1c->conn, h1s);
goto err;
}
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 6cb2334..9ed2727 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -1629,7 +1629,7 @@
*/
sess->t_idle = tv_ms_elapsed(&sess->tv_accept, &now) - sess->t_handshake;
- if (!cs_new_from_mux(h2s->endp, sess, input))
+ if (!cs_new_from_endp(h2s->endp, sess, input))
goto out_close;
h2c->nb_cs++;
diff --git a/src/mux_pt.c b/src/mux_pt.c
index fa92ed6..821f558 100644
--- a/src/mux_pt.c
+++ b/src/mux_pt.c
@@ -302,7 +302,7 @@
ctx->endp->ctx = conn;
ctx->endp->flags |= (CS_EP_T_MUX|CS_EP_ORPHAN);
- cs = cs_new_from_mux(ctx->endp, sess, input);
+ cs = cs_new_from_endp(ctx->endp, sess, input);
if (!cs) {
TRACE_ERROR("CS allocation failure", PT_EV_STRM_NEW|PT_EV_STRM_END|PT_EV_STRM_ERR, conn);
goto fail_free_endp;
diff --git a/src/peers.c b/src/peers.c
index f521b55..58f771b 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -3194,7 +3194,7 @@
if (!sockaddr_alloc(&addr, &peer->addr, sizeof(peer->addr)))
goto out_free_sess;
- cs = cs_new_from_applet(appctx->endp, sess, &BUF_NULL);
+ cs = cs_new_from_endp(appctx->endp, sess, &BUF_NULL);
if (!cs) {
ha_alert("Failed to initialize stream in peer_session_create().\n");
goto out_free_addr;
diff --git a/src/sink.c b/src/sink.c
index 3dc4a4d..c52afc6 100644
--- a/src/sink.c
+++ b/src/sink.c
@@ -654,7 +654,7 @@
if (!sockaddr_alloc(&addr, &sft->srv->addr, sizeof(sft->srv->addr)))
goto out_free_sess;
- cs = cs_new_from_applet(appctx->endp, sess, &BUF_NULL);
+ cs = cs_new_from_endp(appctx->endp, sess, &BUF_NULL);
if (!cs) {
ha_alert("Failed to initialize stream in sink_forward_session_create().\n");
goto out_free_addr;