sess->resp_conns--;
LIST_DEL(&conn->session_list);
}
- /* If we temporarily stored the connection as the stream_interface's
- * end point, remove it.
+
+ /* By convention we always place a NULL where the ctx points to if the
+ * mux is null. It may have been used to store the connection as a
+ * stream_interface's end point for example.
*/
- if (conn->ctx != NULL && conn->mux == NULL) {
- struct stream *s = conn->ctx;
+ if (conn->ctx != NULL && conn->mux == NULL)
+ *(void **)conn->ctx = NULL;
- if (objt_conn(s->si[1].end) == conn)
- s->si[1].end = NULL;
- }
/* The connection is currently in the server's idle list, so tell it
* there's one less connection available in that list.
*/
#if defined(USE_OPENSSL) && defined(TLSEXT_TYPE_application_layer_protocol_negotiation)
/*
* Pick the right mux once the connection is established, we should now have
- * an alpn if available, so we are now able to choose.
+ * an alpn if available, so we are now able to choose. In this specific case
+ * the connection's context is &si[i].end.
*/
static int conn_complete_server(struct connection *conn)
{
struct conn_stream *cs = NULL;
- struct stream *s = conn->ctx;
+ struct stream *s = container_of(conn->ctx, struct stream, si[1].end);
struct server *srv;
task_wakeup(s->task, TASK_WOKEN_IO);
if (unlikely(!(conn->flags & (CO_FL_WAIT_L4_CONN | CO_FL_WAIT_L6_CONN | CO_FL_CONNECTED))))
conn->flags |= CO_FL_CONNECTED;
- if (!s)
- goto fail;
if (conn->flags & CO_FL_ERROR)
goto fail;
si_detach_endpoint(&s->si[1]);
}
#if defined(USE_OPENSSL) && defined(TLSEXT_TYPE_application_layer_protocol_negotiation)
else {
- srv_conn->ctx = s;
+ srv_conn->ctx = &s->si[1].end;
/* Store the connection into the stream interface,
* while we still don't have a mux, so that if the
* stream is destroyed before the connection is