diff --git a/src/protossl.c b/src/protossl.c index 6893c24..41279a2 100644 --- a/src/protossl.c +++ b/src/protossl.c @@ -1530,9 +1530,8 @@ protossl_setup_dst_child(pxy_conn_child_ctx_t *ctx) { if (!ctx->conn->srvdst_xferred) { // Reuse srvdst of parent in the first child conn - ctx->conn->srvdst_xferred = 1; - ctx->srvdst_xferred = 1; ctx->dst = ctx->conn->srvdst; + ctx->conn->srvdst_xferred = 1; // See the comments in prototcp_setup_dst() prototcp_disable_events_srvdst(ctx->conn); diff --git a/src/prototcp.c b/src/prototcp.c index cef20f0..f85aa48 100644 --- a/src/prototcp.c +++ b/src/prototcp.c @@ -205,9 +205,8 @@ prototcp_setup_dst_child(pxy_conn_child_ctx_t *ctx) { if (!ctx->conn->srvdst_xferred) { // Reuse srvdst of parent in the first child conn - ctx->conn->srvdst_xferred = 1; - ctx->srvdst_xferred = 1; ctx->dst = ctx->conn->srvdst; + ctx->conn->srvdst_xferred = 1; // See the comments in prototcp_setup_dst() prototcp_disable_events_srvdst(ctx->conn); diff --git a/src/pxyconn.c b/src/pxyconn.c index f5740e2..9262bcc 100644 --- a/src/pxyconn.c +++ b/src/pxyconn.c @@ -258,7 +258,7 @@ pxy_conn_free_child(pxy_conn_child_ctx_t *ctx) // Save conn and srvdst_xferred before freeing ctx pxy_conn_ctx_t *conn = ctx->conn; - unsigned int srvdst_xferred = ctx->srvdst_xferred; + unsigned int srvdst_xferred = conn->srvdst_xferred; pxy_conn_detach_child(ctx); pxy_conn_ctx_free_child(ctx); diff --git a/src/pxyconn.h b/src/pxyconn.h index d5e0e2d..6fb229f 100644 --- a/src/pxyconn.h +++ b/src/pxyconn.h @@ -255,6 +255,8 @@ struct pxy_conn_ctx { unsigned int term : 1; /* 0 until term requested */ unsigned int term_requestor : 1; /* 1 client, 0 server side */ + // srvdst_xferred flag is important not to access srvdst.bev + // after the first child is freed unsigned int srvdst_xferred : 1; /* 1 if srvdst xferred to child */ struct pxy_conn_desc srvdst; @@ -391,8 +393,6 @@ struct pxy_conn_child_ctx { /* status flags */ unsigned int connected : 1; /* 0 until both ends are connected */ unsigned int term : 1; /* 0 until term requested */ - // srvdst_xferred flag is important not to access the srvdst.bev of parent after the first child is freed - unsigned int srvdst_xferred : 1; /* 1 if srvdst xferred from parent */ // For statistics only evutil_socket_t dst_fd;