mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 15:47:01 +02:00
MEDIUM: connections: Implement a start() method for xprt_handshake.
Add a start_method to xprt_handshake. It schedules the tasklet that does the handshake. This used to be done in xprt_handshake_add_xprt(), but that's a much better place.
This commit is contained in:
parent
1b3c931bff
commit
d54ede7d08
@ -127,6 +127,22 @@ struct task *xprt_handshake_io_cb(struct task *t, void *bctx, unsigned int state
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int xprt_handshake_start(struct connection *conn, void *xprt_ctx)
|
||||||
|
{
|
||||||
|
struct xprt_handshake_ctx *ctx = xprt_ctx;
|
||||||
|
|
||||||
|
if (ctx->xprt->start) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = ctx->xprt->start(conn, ctx->xprt_ctx);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
tasklet_wakeup(ctx->wait_event.tasklet);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int xprt_handshake_init(struct connection *conn, void **xprt_ctx)
|
static int xprt_handshake_init(struct connection *conn, void **xprt_ctx)
|
||||||
{
|
{
|
||||||
struct xprt_handshake_ctx *ctx;
|
struct xprt_handshake_ctx *ctx;
|
||||||
@ -149,10 +165,7 @@ static int xprt_handshake_init(struct connection *conn, void **xprt_ctx)
|
|||||||
ctx->wait_event.tasklet->process = xprt_handshake_io_cb;
|
ctx->wait_event.tasklet->process = xprt_handshake_io_cb;
|
||||||
ctx->wait_event.tasklet->context = ctx;
|
ctx->wait_event.tasklet->context = ctx;
|
||||||
ctx->wait_event.events = 0;
|
ctx->wait_event.events = 0;
|
||||||
/* This XPRT expects the underlying XPRT to be provided later,
|
|
||||||
* with an add_xprt() call, so we start trying to do the handshake
|
|
||||||
* there, when we'll be provided an XPRT.
|
|
||||||
*/
|
|
||||||
ctx->xprt = NULL;
|
ctx->xprt = NULL;
|
||||||
ctx->xprt_ctx = NULL;
|
ctx->xprt_ctx = NULL;
|
||||||
ctx->subs = NULL;
|
ctx->subs = NULL;
|
||||||
@ -242,8 +255,7 @@ static int xprt_handshake_add_xprt(struct connection *conn, void *xprt_ctx, void
|
|||||||
*oldxprt_ctx = ctx->xprt_ctx;
|
*oldxprt_ctx = ctx->xprt_ctx;
|
||||||
ctx->xprt = toadd_ops;
|
ctx->xprt = toadd_ops;
|
||||||
ctx->xprt_ctx = toadd_ctx;
|
ctx->xprt_ctx = toadd_ctx;
|
||||||
/* Ok we know have an xprt, so let's try to do the handshake */
|
|
||||||
tasklet_wakeup(ctx->wait_event.tasklet);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,6 +283,7 @@ struct xprt_ops xprt_handshake = {
|
|||||||
.remove_xprt = xprt_handshake_remove_xprt,
|
.remove_xprt = xprt_handshake_remove_xprt,
|
||||||
.add_xprt = xprt_handshake_add_xprt,
|
.add_xprt = xprt_handshake_add_xprt,
|
||||||
.init = xprt_handshake_init,
|
.init = xprt_handshake_init,
|
||||||
|
.start = xprt_handshake_start,
|
||||||
.close= xprt_handshake_close,
|
.close= xprt_handshake_close,
|
||||||
.rcv_pipe = NULL,
|
.rcv_pipe = NULL,
|
||||||
.snd_pipe = NULL,
|
.snd_pipe = NULL,
|
||||||
|
Loading…
Reference in New Issue
Block a user