struct conn_stream *cs_new_from_check(struct check *check, unsigned int flags);
void cs_free(struct conn_stream *cs);
-void cs_attach_mux(struct conn_stream *cs, void *target, void *ctx);
+int cs_attach_mux(struct conn_stream *cs, void *target, void *ctx);
void cs_attach_applet(struct conn_stream *cs, void *target, void *ctx);
int cs_attach_strm(struct conn_stream *cs, struct stream *strm);
return SF_ERR_INTERNAL; /* how did we get there ? */
}
- cs_attach_mux(s->csb, NULL, srv_conn);
+ if (cs_attach_mux(s->csb, NULL, srv_conn) < 0) {
+ conn_free(srv_conn);
+ return SF_ERR_INTERNAL; /* how did we get there ? */
+ }
srv_conn->ctx = s->csb;
#if defined(USE_OPENSSL) && defined(TLSEXT_TYPE_application_layer_protocol_negotiation)
/* Attaches a conn_stream to an mux endpoint and sets the endpoint ctx */
-void cs_attach_mux(struct conn_stream *cs, void *target, void *ctx)
+int cs_attach_mux(struct conn_stream *cs, void *target, void *ctx)
{
struct connection *conn = ctx;
}
else if (cs_check(cs))
cs->data_cb = &check_conn_cb;
+ return 0;
}
/* Attaches a conn_stream to an applet endpoint and sets the endpoint ctx */
TRACE_ERROR("fstream allocation failure", FCGI_EV_FSTRM_NEW|FCGI_EV_FSTRM_END|FCGI_EV_FSTRM_ERR, fconn->conn);
goto out;
}
- cs_attach_mux(cs, fstrm, fconn->conn);
+ if (cs_attach_mux(cs, fstrm, fconn->conn) < 0)
+ goto out;
fstrm->cs = cs;
fstrm->endp = cs->endp;
fstrm->sess = sess;
out:
TRACE_DEVEL("leaving on error", FCGI_EV_FSTRM_NEW|FCGI_EV_FSTRM_END|FCGI_EV_FSTRM_ERR, fconn->conn);
+ fcgi_strm_destroy(fstrm);
return NULL;
}
goto fail;
if (cs) {
- cs_attach_mux(cs, h1s, h1c->conn);
+ if (cs_attach_mux(cs, h1s, h1c->conn) < 0)
+ goto fail;
h1s->cs = cs;
h1s->endp = cs->endp;
}
if (!h1s)
goto fail;
- cs_attach_mux(cs, h1s, h1c->conn);
+ if (cs_attach_mux(cs, h1s, h1c->conn) < 0)
+ goto fail;
+
h1s->flags |= H1S_F_RX_BLK;
h1s->cs = cs;
h1s->endp = cs->endp;
fail:
TRACE_DEVEL("leaving on error", H1_EV_STRM_NEW|H1_EV_STRM_ERR, h1c->conn);
+ pool_free(pool_head_h1s, h1s);
return NULL;
}
if (!h2s)
goto out;
- cs_attach_mux(cs, h2s, h2c->conn);
+ if (cs_attach_mux(cs, h2s, h2c->conn) < 0) {
+ h2s_destroy(h2s);
+ h2s = NULL;
+ goto out;
+ }
h2s->cs = cs;
h2s->endp = cs->endp;
h2s->sess = sess;
TRACE_POINT(PT_EV_STRM_NEW, conn, cs);
}
else {
- cs_attach_mux(cs, ctx, conn);
+ if (cs_attach_mux(cs, ctx, conn) < 0)
+ goto fail_free_ctx;
ctx->endp = cs->endp;
}
conn->ctx = ctx;
TRACE_ENTER(PT_EV_STRM_NEW, conn);
if (ctx->wait_event.events)
conn->xprt->unsubscribe(ctx->conn, conn->xprt_ctx, SUB_RETRY_RECV, &ctx->wait_event);
- cs_attach_mux(cs, ctx, conn);
+ if (cs_attach_mux(cs, ctx, conn) < 0)
+ return -1;
ctx->cs = cs;
ctx->endp = cs->endp;
ctx->endp->flags |= CS_EP_RCV_MORE;
TRACE_ERROR("conn-stream allocation error", CHK_EV_TCPCHK_CONN|CHK_EV_TCPCHK_ERR, check);
goto out;
}
- cs_attach_mux(check->cs, NULL, conn);
+ if (cs_attach_mux(check->cs, NULL, conn) < 0) {
+ TRACE_ERROR("mux attach error", CHK_EV_TCPCHK_CONN|CHK_EV_TCPCHK_ERR, check);
+ conn_free(conn);
+ conn = NULL;
+ status = SF_ERR_RESOURCE;
+ goto fail_check;
+ }
conn->ctx = check->cs;
tasklet_set_tid(check->wait_list.tasklet, tid);
conn_set_owner(conn, check->sess, NULL);