mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-17 11:06:54 +00:00
MINOR: connection: introduce conn_stream
This patch introduces a new struct conn_stream. It's the stream-side of a multiplexed connection. A pool is created and destroyed on exit. For now the conn_streams are not used at all.
This commit is contained in:
parent
60ca10a372
commit
e2b40b9eab
@ -31,6 +31,7 @@
|
||||
#include <proto/obj_type.h>
|
||||
|
||||
extern struct pool_head *pool2_connection;
|
||||
extern struct pool_head *pool2_connstream;
|
||||
extern struct xprt_ops *registered_xprt[XPRT_ENTRIES];
|
||||
extern struct alpn_mux_list alpn_mux_list;
|
||||
|
||||
@ -552,6 +553,11 @@ static inline void conn_free(struct connection *conn)
|
||||
pool_free2(pool2_connection, conn);
|
||||
}
|
||||
|
||||
/* Returns the conn from a cs. If cs is NULL, returns NULL */
|
||||
static inline struct connection *cs_conn(const struct conn_stream *cs)
|
||||
{
|
||||
return cs ? cs->conn : NULL;
|
||||
}
|
||||
|
||||
/* Retrieves the connection's source address */
|
||||
static inline void conn_get_from_addr(struct connection *conn)
|
||||
|
@ -119,6 +119,18 @@ static inline struct appctx *objt_appctx(enum obj_type *t)
|
||||
return __objt_appctx(t);
|
||||
}
|
||||
|
||||
static inline struct conn_stream *__objt_cs(enum obj_type *t)
|
||||
{
|
||||
return (container_of(t, struct conn_stream, obj_type));
|
||||
}
|
||||
|
||||
static inline struct conn_stream *objt_cs(enum obj_type *t)
|
||||
{
|
||||
if (!t || *t != OBJ_TYPE_CS)
|
||||
return NULL;
|
||||
return __objt_cs(t);
|
||||
}
|
||||
|
||||
static inline struct connection *__objt_conn(enum obj_type *t)
|
||||
{
|
||||
return container_of(t, struct connection, obj_type);
|
||||
@ -152,6 +164,7 @@ static inline void *obj_base_ptr(enum obj_type *t)
|
||||
case OBJ_TYPE_APPLET: return __objt_applet(t);
|
||||
case OBJ_TYPE_APPCTX: return __objt_appctx(t);
|
||||
case OBJ_TYPE_CONN: return __objt_conn(t);
|
||||
case OBJ_TYPE_CS: return __objt_cs(t);
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
/* referenced below */
|
||||
struct connection;
|
||||
struct conn_stream;
|
||||
struct buffer;
|
||||
struct server;
|
||||
struct pipe;
|
||||
@ -51,6 +52,15 @@ union conn_handle {
|
||||
int fd; /* file descriptor, for regular sockets */
|
||||
};
|
||||
|
||||
/* conn_stream flags */
|
||||
enum {
|
||||
CS_FL_NONE = 0x00000000, /* Just for initialization purposes */
|
||||
CS_FL_DATA_RD_ENA = 0x00000001, /* receiving data is allowed */
|
||||
CS_FL_DATA_WR_ENA = 0x00000002, /* sending data is desired */
|
||||
|
||||
CS_FL_ERROR = 0x00000100, /* a fatal error was reported */
|
||||
CS_FL_EOS = 0x00001000, /* End of stream */
|
||||
};
|
||||
|
||||
/* For each direction, we have a CO_FL_{SOCK,DATA}_<DIR>_ENA flag, which
|
||||
* indicates if read or write is desired in that direction for the respective
|
||||
@ -297,6 +307,18 @@ struct conn_src {
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* This structure describes the elements of a connection relevant to a stream
|
||||
*/
|
||||
struct conn_stream {
|
||||
enum obj_type obj_type; /* differentiates connection from applet context */
|
||||
struct connection *conn; /* xprt-level connection */
|
||||
unsigned int flags; /* CS_FL_* */
|
||||
void *data; /* pointer to upper layer's entity (eg: stream interface) */
|
||||
const struct data_cb *data_cb; /* data layer callbacks. Must be set before xprt->init() */
|
||||
void *ctx; /* mux-specific context */
|
||||
};
|
||||
|
||||
/* This structure describes a connection with its methods and data.
|
||||
* A connection may be performed to proxy or server via a local or remote
|
||||
* socket, and can also be made to an internal applet. It can support
|
||||
|
@ -40,6 +40,7 @@ enum obj_type {
|
||||
OBJ_TYPE_APPCTX, /* object is a struct appctx */
|
||||
OBJ_TYPE_CONN, /* object is a struct connection */
|
||||
OBJ_TYPE_SRVRQ, /* object is a struct dns_srvrq */
|
||||
OBJ_TYPE_CS, /* object is a struct conn_stream */
|
||||
OBJ_TYPE_ENTRIES /* last one : number of entries */
|
||||
} __attribute__((packed)) ;
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#endif
|
||||
|
||||
struct pool_head *pool2_connection;
|
||||
struct pool_head *pool2_connstream;
|
||||
struct xprt_ops *registered_xprt[XPRT_ENTRIES] = { NULL, };
|
||||
|
||||
/* List head of all known muxes for ALPN */
|
||||
@ -39,7 +40,19 @@ struct alpn_mux_list alpn_mux_list = {
|
||||
int init_connection()
|
||||
{
|
||||
pool2_connection = create_pool("connection", sizeof (struct connection), MEM_F_SHARED);
|
||||
return pool2_connection != NULL;
|
||||
if (!pool2_connection)
|
||||
goto fail_conn;
|
||||
|
||||
pool2_connstream = create_pool("conn_stream", sizeof(struct conn_stream), MEM_F_SHARED);
|
||||
if (!pool2_connstream)
|
||||
goto fail_cs;
|
||||
|
||||
return 1;
|
||||
fail_cs:
|
||||
pool_destroy2(pool2_connection);
|
||||
pool2_connection = NULL;
|
||||
fail_conn:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* I/O callback for fd-based connections. It calls the read/write handlers
|
||||
|
@ -2189,6 +2189,7 @@ void deinit(void)
|
||||
pool_destroy2(pool2_stream);
|
||||
pool_destroy2(pool2_session);
|
||||
pool_destroy2(pool2_connection);
|
||||
pool_destroy2(pool2_connstream);
|
||||
pool_destroy2(pool2_requri);
|
||||
pool_destroy2(pool2_task);
|
||||
pool_destroy2(pool2_capture);
|
||||
|
Loading…
Reference in New Issue
Block a user