int (*subscribe)(struct conn_stream *cs, int event_type, void *param); /* Subscribe to events, such as "being able to send" */
int (*unsubscribe)(struct conn_stream *cs, int event_type, void *param); /* Unsubscribe to events */
int (*avail_streams)(struct connection *conn); /* Returns the number of streams still available for a connection */
+ void (*destroy)(struct connection *conn); /* Let the mux know one of its users left, so it may have to disappear */
unsigned int flags; /* some flags characterizing the mux's capabilities (MX_FL_*) */
char name[8]; /* mux layer name, zero-terminated */
};
return (h2_process(h2c));
}
-
/* Connection timeout management. The principle is that if there's no receipt
* nor sending for a certain amount of time, the connection is closed. If the
* MUX buffer still has lying data or is not allocatable, the connection is
return NULL;
}
+/*
+ * Destroy the mux and the associated connection, if it is no longer used
+ */
+static void h2_destroy(struct connection *conn)
+{
+ struct h2c *h2c = conn->mux_ctx;
+
+ if (eb_is_empty(&h2c->streams_by_id))
+ h2_release(h2c->conn);
+}
+
/*
* Detach the stream from the connection and possibly release the connection.
*/
.attach = h2_attach,
.get_first_cs = h2_get_first_cs,
.detach = h2_detach,
+ .destroy = h2_destroy,
.avail_streams = h2_avail_streams,
.shutr = h2_shutr,
.shutw = h2_shutw,
return cs;
}
+/* Destroy the mux and the associated connection */
+static void mux_pt_destroy_meth(struct connection *conn)
+{
+ mux_pt_destroy(conn->mux_ctx);
+}
+
/*
* Detach the stream from the connection and possibly release the connection.
*/
.get_first_cs = mux_pt_get_first_cs,
.detach = mux_pt_detach,
.avail_streams = mux_pt_avail_streams,
+ .destroy = mux_pt_destroy_meth,
.shutr = mux_pt_shutr,
.shutw = mux_pt_shutw,
.flags = MX_FL_NONE,