MEDIUM: connections: Provide a xprt_ctx for each xprt method.
For most of the xprt methods, provide a xprt_ctx. This will be useful later
when we'll want to be able to stack xprts.
The init() method now has to create and provide the said xprt_ctx if needed.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index 3a88f58..f0a4841 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -48,8 +48,8 @@
int make_proxy_line_v1(char *buf, int buf_len, struct sockaddr_storage *src, struct sockaddr_storage *dst);
int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct connection *remote);
-int conn_subscribe(struct connection *conn, int event_type, void *param);
-int conn_unsubscribe(struct connection *conn, int event_type, void *param);
+int conn_subscribe(struct connection *conn, void *xprt_ctx, int event_type, void *param);
+int conn_unsubscribe(struct connection *conn, void *xprt_ctx, int event_type, void *param);
/* receive a NetScaler Client IP insertion header over a connection */
int conn_recv_netscaler_cip(struct connection *conn, int flag);
@@ -81,7 +81,7 @@
int ret = 0;
if (!conn_xprt_ready(conn) && conn->xprt && conn->xprt->init)
- ret = conn->xprt->init(conn);
+ ret = conn->xprt->init(conn, &conn->xprt_ctx);
if (ret >= 0)
conn->flags |= CO_FL_XPRT_READY;
@@ -98,7 +98,7 @@
{
if ((conn->flags & (CO_FL_XPRT_READY|CO_FL_XPRT_TRACKED)) == CO_FL_XPRT_READY) {
if (conn->xprt->close)
- conn->xprt->close(conn);
+ conn->xprt->close(conn, conn->xprt_ctx);
conn->flags &= ~CO_FL_XPRT_READY;
}
}
@@ -462,7 +462,7 @@
/* clean data-layer shutdown */
if (c->xprt && c->xprt->shutw)
- c->xprt->shutw(c, 1);
+ c->xprt->shutw(c, c->xprt_ctx, 1);
}
static inline void conn_xprt_shutw_hard(struct connection *c)
@@ -471,7 +471,7 @@
/* unclean data-layer shutdown */
if (c->xprt && c->xprt->shutw)
- c->xprt->shutw(c, 0);
+ c->xprt->shutw(c, c->xprt_ctx, 0);
}
/* shut read */
@@ -940,7 +940,7 @@
{
if (!conn_xprt_ready(conn) || !conn->xprt->get_alpn)
return 0;
- return conn->xprt->get_alpn(conn, str, len);
+ return conn->xprt->get_alpn(conn, conn->xprt_ctx, str, len);
}
/* registers proto mux list <list>. Modifies the list element! */
diff --git a/include/types/connection.h b/include/types/connection.h
index dd4935d..308be7d 100644
--- a/include/types/connection.h
+++ b/include/types/connection.h
@@ -302,22 +302,22 @@
* and the other ones are used to setup and release the transport layer.
*/
struct xprt_ops {
- size_t (*rcv_buf)(struct connection *conn, struct buffer *buf, size_t count, int flags); /* recv callback */
- size_t (*snd_buf)(struct connection *conn, const struct buffer *buf, size_t count, int flags); /* send callback */
- int (*rcv_pipe)(struct connection *conn, struct pipe *pipe, unsigned int count); /* recv-to-pipe callback */
- int (*snd_pipe)(struct connection *conn, struct pipe *pipe); /* send-to-pipe callback */
- void (*shutr)(struct connection *, int); /* shutr function */
- void (*shutw)(struct connection *, int); /* shutw function */
- void (*close)(struct connection *); /* close the transport layer */
- int (*init)(struct connection *conn); /* initialize the transport layer */
+ size_t (*rcv_buf)(struct connection *conn, void *xprt_ctx, struct buffer *buf, size_t count, int flags); /* recv callback */
+ size_t (*snd_buf)(struct connection *conn, void *xprt_ctx, const struct buffer *buf, size_t count, int flags); /* send callback */
+ int (*rcv_pipe)(struct connection *conn, void *xprt_ctx, struct pipe *pipe, unsigned int count); /* recv-to-pipe callback */
+ int (*snd_pipe)(struct connection *conn, void *xprt_ctx, struct pipe *pipe); /* send-to-pipe callback */
+ void (*shutr)(struct connection *conn, void *xprt_ctx, int); /* shutr function */
+ void (*shutw)(struct connection *conn, void *xprt_ctx, int); /* shutw function */
+ void (*close)(struct connection *conn, void *xprt_ctx); /* close the transport layer */
+ int (*init)(struct connection *conn, void **ctx); /* initialize the transport layer */
int (*prepare_bind_conf)(struct bind_conf *conf); /* prepare a whole bind_conf */
void (*destroy_bind_conf)(struct bind_conf *conf); /* destroy a whole bind_conf */
int (*prepare_srv)(struct server *srv); /* prepare a server context */
void (*destroy_srv)(struct server *srv); /* destroy a server context */
- int (*get_alpn)(const struct connection *conn, const char **str, int *len); /* get application layer name */
+ int (*get_alpn)(const struct connection *conn, void *xprt_ctx, const char **str, int *len); /* get application layer name */
char name[8]; /* transport layer name, zero-terminated */
- int (*subscribe)(struct connection *conn, int event_type, void *param); /* Subscribe to events, such as "being able to send" */
- int (*unsubscribe)(struct connection *conn, int event_type, void *param); /* Unsubscribe to events */
+ int (*subscribe)(struct connection *conn, void *xprt_ctx, int event_type, void *param); /* Subscribe to events, such as "being able to send" */
+ int (*unsubscribe)(struct connection *conn, void *xprt_ctx, int event_type, void *param); /* Unsubscribe to events */
};
/* mux_ops describes the mux operations, which are to be performed at the