MINOR: stream-int: Add function to reset a SI endpoint

si_reset_endpoint() function may be used to reset the SI's endpoint without
releasing the conn-stream if the endpoint is a connection. If the endpoint
is an appctx, it is released. This change is mandatory to merge the SI and
the CS and keep the backend conn-stream attached to the stream during
connection retries.
This commit is contained in:
Christopher Faulet 2021-12-16 14:41:29 +01:00
parent 2b4e8b7b2d
commit 20a6501051

View File

@ -166,6 +166,33 @@ static inline enum obj_type *si_detach_endpoint(struct stream_interface *si)
return prev;
}
/* Reset the endpoint if it's a connection or an applet, For an applet, it is
* for now the same than si_release_endpoint(), the appctx is freed. But for a
* connection, the conn-stream is only detached.
*/
static inline void si_reset_endpoint(struct stream_interface *si)
{
struct conn_stream *cs;
struct appctx *appctx;
if (!si->end)
return;
if ((appctx = objt_appctx(si->end))) {
if (appctx->applet->release && !si_state_in(si->state, SI_SB_DIS|SI_SB_CLO))
appctx->applet->release(appctx);
appctx_free(appctx);
si_detach_endpoint(si);
}
else if ((cs = objt_cs(si->end))) {
if (cs_conn(cs) && si->wait_event.events != 0)
cs->conn->mux->unsubscribe(cs, si->wait_event.events,
&si->wait_event);
cs_detach(cs);
si->ops = &si_embedded_ops;
}
}
/* Release the endpoint if it's a connection or an applet, then nullify it.
* Note: released connections are closed then freed.
*/