diff --git a/src/dns.c b/src/dns.c index bfd22c1b9..716514b04 100644 --- a/src/dns.c +++ b/src/dns.c @@ -934,9 +934,10 @@ static struct appctx *dns_session_create(struct dns_session *ds) ha_alert("out of memory in dns_session_create().\n"); goto out_free_appctx; } + appctx->sess = sess; if (!sockaddr_alloc(&addr, &ds->dss->srv->addr, sizeof(ds->dss->srv->addr))) - goto out_free_sess; + goto out_free_appctx; cs = cs_new_from_endp(appctx->endp, sess, &BUF_NULL); if (!cs) { @@ -965,8 +966,6 @@ static struct appctx *dns_session_create(struct dns_session *ds) /* Error unrolling */ out_free_addr: sockaddr_free(&addr); - out_free_sess: - session_free(sess); out_free_appctx: appctx_free(appctx); out_close: diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 030ba9c8a..c176a9b41 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -2026,9 +2026,10 @@ spoe_create_appctx(struct spoe_config *conf) if (!sess) goto out_free_spoe; + appctx->sess = sess; cs = cs_new_from_endp(appctx->endp, sess, &BUF_NULL); if (!cs) - goto out_free_sess; + goto out_free_spoe; strm = DISGUISE(cs_strm(cs)); stream_set_backend(strm, conf->agent->b.be); @@ -2049,8 +2050,6 @@ spoe_create_appctx(struct spoe_config *conf) return appctx; /* Error unrolling */ - out_free_sess: - session_free(sess); out_free_spoe: task_destroy(SPOE_APPCTX(appctx)->task); out_free_spoe_appctx: diff --git a/src/hlua.c b/src/hlua.c index abe3556b6..193956a91 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -2994,10 +2994,11 @@ __LJMP static int hlua_socket_new(lua_State *L) goto out_fail_appctx; } + appctx->sess = sess; cs = cs_new_from_endp(appctx->endp, sess, &BUF_NULL); if (!cs) { hlua_pusherror(L, "socket: out of memory"); - goto out_fail_sess; + goto out_fail_appctx; } s = DISGUISE(cs_strm(cs)); @@ -3017,8 +3018,6 @@ __LJMP static int hlua_socket_new(lua_State *L) return 1; - out_fail_sess: - session_free(sess); out_fail_appctx: appctx_free(appctx); out_fail_conf: diff --git a/src/http_client.c b/src/http_client.c index 4daacea1d..b818396f8 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -578,6 +578,7 @@ struct appctx *httpclient_start(struct httpclient *hc) ha_alert("httpclient: out of memory in %s:%d.\n", __FUNCTION__, __LINE__); goto out_free_appctx; } + appctx->sess = sess; /* choose the SSL server or not */ switch (scheme) { @@ -590,22 +591,22 @@ struct appctx *httpclient_start(struct httpclient *hc) target = &httpclient_srv_ssl->obj_type; } else { ha_alert("httpclient: SSL was disabled (wrong verify/ca-file)!\n"); - goto out_free_sess; + goto out_free_appctx; } #else ha_alert("httpclient: OpenSSL is not available %s:%d.\n", __FUNCTION__, __LINE__); - goto out_free_sess; + goto out_free_appctx; #endif break; } if (!ss_dst) { ha_alert("httpclient: Failed to initialize address %s:%d.\n", __FUNCTION__, __LINE__); - goto out_free_sess; + goto out_free_appctx; } if (!sockaddr_alloc(&addr, ss_dst, sizeof(*ss_dst))) - goto out_free_sess; + goto out_free_appctx; cs = cs_new_from_endp(appctx->endp, sess, &hc->req.buf); if (!cs) { @@ -650,8 +651,6 @@ struct appctx *httpclient_start(struct httpclient *hc) out_free_addr: sockaddr_free(&addr); -out_free_sess: - session_free(sess); out_free_appctx: appctx_free(appctx); out: diff --git a/src/peers.c b/src/peers.c index 58f771b97..07520a4b4 100644 --- a/src/peers.c +++ b/src/peers.c @@ -3190,14 +3190,15 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer ha_alert("out of memory in peer_session_create().\n"); goto out_free_appctx; } + appctx->sess = sess; if (!sockaddr_alloc(&addr, &peer->addr, sizeof(peer->addr))) - goto out_free_sess; + goto out_free_appctx; 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; + goto out_free_appctx; } s = DISGUISE(cs_strm(cs)); @@ -3224,8 +3225,6 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer /* Error unrolling */ out_free_addr: sockaddr_free(&addr); - out_free_sess: - session_free(sess); out_free_appctx: appctx_free(appctx); out_close: diff --git a/src/sink.c b/src/sink.c index c52afc68d..59391859e 100644 --- a/src/sink.c +++ b/src/sink.c @@ -650,14 +650,15 @@ static struct appctx *sink_forward_session_create(struct sink *sink, struct sink ha_alert("out of memory in sink_forward_session_create().\n"); goto out_free_appctx; } + appctx->sess = sess; if (!sockaddr_alloc(&addr, &sft->srv->addr, sizeof(sft->srv->addr))) - goto out_free_sess; + goto out_free_appctx; 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; + goto out_free_appctx; } s = DISGUISE(cs_strm(cs)); @@ -682,8 +683,6 @@ static struct appctx *sink_forward_session_create(struct sink *sink, struct sink /* Error unrolling */ out_free_addr: sockaddr_free(&addr); - out_free_sess: - session_free(sess); out_free_appctx: appctx_free(appctx); out_close: diff --git a/src/stream.c b/src/stream.c index c7002366f..00abce656 100644 --- a/src/stream.c +++ b/src/stream.c @@ -585,7 +585,6 @@ static void stream_free(struct stream *s) struct session *sess = strm_sess(s); struct proxy *fe = sess->fe; struct bref *bref, *back; - int must_free_sess; int i; DBG_TRACE_POINT(STRM_EV_STRM_FREE, s); @@ -709,18 +708,9 @@ static void stream_free(struct stream *s) } LIST_DELETE(&s->list); - /* applets do not release session yet */ - /* FIXME: Handle it in appctx_free ??? */ - must_free_sess = objt_appctx(sess->origin) && sess->origin == __cs_endp_target(s->csf); - cs_destroy(s->csb); cs_destroy(s->csf); - if (must_free_sess) { - sess->origin = NULL; - session_free(sess); - } - pool_free(pool_head_stream, s); /* We may want to free the maximum amount of pools if the proxy is stopping */