Index: modules/proxy/mod_proxy_wstunnel.c =================================================================== --- modules/proxy/mod_proxy_wstunnel.c (revision 1581864) +++ modules/proxy/mod_proxy_wstunnel.c (working copy) @@ -103,10 +103,12 @@ rv = ap_get_brigade(c_i->input_filters, bb, AP_MODE_READBYTES, APR_NONBLOCK_READ, AP_IOBUFSIZE); if (rv == APR_SUCCESS) { - if (c_o->aborted) + if (c_o->aborted) { return APR_EPIPE; - if (APR_BRIGADE_EMPTY(bb)) + } + if (APR_BRIGADE_EMPTY(bb)) { break; + } #ifdef DEBUGGING len = -1; apr_brigade_length(bb, 0, &len); @@ -178,7 +180,6 @@ conn_rec *c = r->connection; apr_socket_t *sock = conn->sock; conn_rec *backconn = conn->connection; - int client_error = 0; char *buf; apr_bucket_brigade *header_brigade; apr_bucket *e; @@ -224,7 +225,7 @@ pollfd.p = p; pollfd.desc_type = APR_POLL_SOCKET; - pollfd.reqevents = APR_POLLIN; + pollfd.reqevents = APR_POLLIN | APR_POLLHUP; pollfd.desc.s = sock; pollfd.client_data = NULL; apr_pollset_add(pollset, &pollfd); @@ -237,6 +238,9 @@ r->proto_output_filters = c->output_filters; r->input_filters = c->input_filters; r->proto_input_filters = c->input_filters; + /* This handler should take care of the entire connection; make it so that + * nothing else is attempted on the connection after returning. */ + c->keepalive = AP_CONN_CLOSE; remove_reqtimeout(r->input_filters); @@ -257,38 +261,34 @@ if (cur->desc.s == sock) { pollevent = cur->rtnevents; - if (pollevent & APR_POLLIN) { + if (pollevent & (APR_POLLIN | APR_POLLHUP)) { ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02446) "sock was readable"); rv = proxy_wstunnel_transfer(r, backconn, c, bb, "sock"); - } - else if ((pollevent & APR_POLLERR) - || (pollevent & APR_POLLHUP)) { - rv = APR_EPIPE; - ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02447) - "err/hup on backconn"); } + else if (pollevent & APR_POLLERR) { + rv = APR_EPIPE; + ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02447) + "error on reading from server conn"); + } else { rv = APR_EGENERAL; ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02605) "unknown event on backconn %d", pollevent); } - if (rv != APR_SUCCESS) - client_error = 1; } else if (cur->desc.s == client_socket) { pollevent = cur->rtnevents; - if (pollevent & APR_POLLIN) { + if (pollevent & (APR_POLLIN | APR_POLLHUP)) { ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02448) "client was readable"); rv = proxy_wstunnel_transfer(r, c, backconn, bb, "client"); } - else if ((pollevent & APR_POLLERR) - || (pollevent & APR_POLLHUP)) { + else if (pollevent & APR_POLLERR) { rv = APR_EPIPE; c->aborted = 1; ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02607) - "err/hup on client conn"); + "error on reading from client conn"); } else { rv = APR_EGENERAL; @@ -311,9 +311,6 @@ ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, "finished with poll() - cleaning up"); - if (client_error) { - return HTTP_INTERNAL_SERVER_ERROR; - } return OK; }