diff --git a/protohttp.c b/protohttp.c index e39fe40..a0657d6 100644 --- a/protohttp.c +++ b/protohttp.c @@ -534,7 +534,6 @@ protohttp_bev_readcb_src(struct bufferevent *bev, pxy_conn_ctx_t *ctx) } else { evbuffer_add_printf(bufferevent_get_output(bev), redirect, ctx->opts->user_auth_url); } - ctx->redirected = 1; return; } diff --git a/prototcp.c b/prototcp.c index 371adfb..579f0ad 100644 --- a/prototcp.c +++ b/prototcp.c @@ -385,12 +385,18 @@ prototcp_bev_writecb_src(struct bufferevent *bev, pxy_conn_ctx_t *ctx) log_dbg_level_printf(LOG_DBG_MODE_FINEST, "prototcp_bev_writecb_src: ENTER, fd=%d\n", ctx->fd); #endif /* DEBUG_PROXY */ - if (ctx->opts->user_auth && !ctx->user && ctx->redirected) { + if (ctx->opts->user_auth && !ctx->user) { + size_t outbuflen = evbuffer_get_length(bufferevent_get_output(bev)); + if (outbuflen > 0) { #ifdef DEBUG_PROXY - log_dbg_level_printf(LOG_DBG_MODE_FINEST, "prototcp_bev_writecb_src: Closing redirected conn, fd=%d\n", ctx->fd); + log_dbg_level_printf(LOG_DBG_MODE_FINEST, "prototcp_bev_writecb_src: Not closing redirected conn, outbuflen=%zu, fd=%d\n", outbuflen, ctx->fd); #endif /* DEBUG_PROXY */ - - pxy_conn_term(ctx, 1); + } else { +#ifdef DEBUG_PROXY + log_dbg_level_printf(LOG_DBG_MODE_FINEST, "prototcp_bev_writecb_src: Closing redirected conn, fd=%d\n", ctx->fd); +#endif /* DEBUG_PROXY */ + pxy_conn_term(ctx, 1); + } return; } diff --git a/pxyconn.h b/pxyconn.h index 81ee0bf..12e7b1b 100644 --- a/pxyconn.h +++ b/pxyconn.h @@ -279,7 +279,6 @@ struct pxy_conn_ctx { unsigned int identify_user_count; char *user; char *ether; - unsigned int redirected : 1; #ifdef HAVE_LOCAL_PROCINFO /* local process information */