Skip to content

Commit

Permalink
Fix passthrough in split mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sonertari committed Sep 2, 2021
1 parent 9123732 commit 74cf380
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/protopassthrough.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,20 @@ protopassthrough_engage(pxy_conn_ctx_t *ctx)
// Free any children of the previous proto
pxy_conn_free_children(ctx);

// If srvdst is xferred, it is freed as the first child_dst
if (!ctx->srvdst_xferred) {
// In split mode, srvdst is used as dst, so it should be freed as dst below
// If srvdst has been xferred to the first child conn, the child should free it, not the parent
if (ctx->spec->opts->divert && !ctx->srvdst_xferred) {
ctx->srvdst.free(ctx->srvdst.bev, ctx);
} else /*if (!ctx->spec->opts->divert || ctx->srvdst_xferred)*/ {
struct bufferevent *ubev = bufferevent_get_underlying(ctx->srvdst.bev);

bufferevent_setcb(ctx->srvdst.bev, NULL, NULL, NULL, NULL);
bufferevent_disable(ctx->srvdst.bev, EV_READ|EV_WRITE);

if (ubev) {
bufferevent_setcb(ubev, NULL, NULL, NULL, NULL);
bufferevent_disable(ubev, EV_READ|EV_WRITE);
}
}
ctx->srvdst.bev = NULL;
ctx->srvdst.ssl = NULL;
Expand Down

0 comments on commit 74cf380

Please sign in to comment.