|
|
41a6c3 |
diff --git a/modules/proxy/mod_proxy_wstunnel.c b/modules/proxy/mod_proxy_wstunnel.c
|
|
|
41a6c3 |
index 525109a..eb34eee 100644
|
|
|
41a6c3 |
--- a/modules/proxy/mod_proxy_wstunnel.c
|
|
|
41a6c3 |
+++ b/modules/proxy/mod_proxy_wstunnel.c
|
|
|
41a6c3 |
@@ -103,10 +103,12 @@ static int proxy_wstunnel_transfer(request_rec *r, conn_rec *c_i, conn_rec *c_o,
|
|
|
41a6c3 |
rv = ap_get_brigade(c_i->input_filters, bb, AP_MODE_READBYTES,
|
|
|
41a6c3 |
APR_NONBLOCK_READ, AP_IOBUFSIZE);
|
|
|
41a6c3 |
if (rv == APR_SUCCESS) {
|
|
|
41a6c3 |
- if (c_o->aborted)
|
|
|
41a6c3 |
+ if (c_o->aborted) {
|
|
|
41a6c3 |
return APR_EPIPE;
|
|
|
41a6c3 |
- if (APR_BRIGADE_EMPTY(bb))
|
|
|
41a6c3 |
+ }
|
|
|
41a6c3 |
+ if (APR_BRIGADE_EMPTY(bb)){
|
|
|
41a6c3 |
break;
|
|
|
41a6c3 |
+ }
|
|
|
41a6c3 |
#ifdef DEBUGGING
|
|
|
41a6c3 |
len = -1;
|
|
|
41a6c3 |
apr_brigade_length(bb, 0, &len;;
|
|
|
41a6c3 |
@@ -178,7 +180,6 @@ static int ap_proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
|
|
|
41a6c3 |
conn_rec *c = r->connection;
|
|
|
41a6c3 |
apr_socket_t *sock = conn->sock;
|
|
|
41a6c3 |
conn_rec *backconn = conn->connection;
|
|
|
41a6c3 |
- int client_error = 0;
|
|
|
41a6c3 |
char *buf;
|
|
|
41a6c3 |
apr_bucket_brigade *header_brigade;
|
|
|
41a6c3 |
apr_bucket *e;
|
|
|
41a6c3 |
@@ -224,7 +225,7 @@ static int ap_proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
|
|
|
41a6c3 |
|
|
|
41a6c3 |
pollfd.p = p;
|
|
|
41a6c3 |
pollfd.desc_type = APR_POLL_SOCKET;
|
|
|
41a6c3 |
- pollfd.reqevents = APR_POLLIN;
|
|
|
41a6c3 |
+ pollfd.reqevents = APR_POLLIN | APR_POLLHUP;
|
|
|
41a6c3 |
pollfd.desc.s = sock;
|
|
|
41a6c3 |
pollfd.client_data = NULL;
|
|
|
41a6c3 |
apr_pollset_add(pollset, &pollfd);
|
|
|
41a6c3 |
@@ -237,6 +238,9 @@ static int ap_proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
|
|
|
41a6c3 |
r->proto_output_filters = c->output_filters;
|
|
|
41a6c3 |
r->input_filters = c->input_filters;
|
|
|
41a6c3 |
r->proto_input_filters = c->input_filters;
|
|
|
41a6c3 |
+ /* This handler should take care of the entire connection; make it so that
|
|
|
41a6c3 |
+ * nothing else is attempted on the connection after returning. */
|
|
|
41a6c3 |
+ c->keepalive = AP_CONN_CLOSE;
|
|
|
41a6c3 |
|
|
|
41a6c3 |
remove_reqtimeout(r->input_filters);
|
|
|
41a6c3 |
|
|
|
41a6c3 |
@@ -257,26 +261,28 @@ static int ap_proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
|
|
|
41a6c3 |
|
|
|
41a6c3 |
if (cur->desc.s == sock) {
|
|
|
41a6c3 |
pollevent = cur->rtnevents;
|
|
|
41a6c3 |
- if (pollevent & APR_POLLIN) {
|
|
|
41a6c3 |
+ if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
|
|
|
41a6c3 |
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02446)
|
|
|
41a6c3 |
"sock was readable");
|
|
|
41a6c3 |
rv = proxy_wstunnel_transfer(r, backconn, c, bb, "sock");
|
|
|
41a6c3 |
}
|
|
|
41a6c3 |
- else if ((pollevent & APR_POLLERR)
|
|
|
41a6c3 |
- || (pollevent & APR_POLLHUP)) {
|
|
|
41a6c3 |
+ else if (pollevent & APR_POLLERR) {
|
|
|
41a6c3 |
rv = APR_EPIPE;
|
|
|
41a6c3 |
ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02447)
|
|
|
41a6c3 |
- "err/hup on backconn");
|
|
|
41a6c3 |
+ "err on backconn");
|
|
|
41a6c3 |
}
|
|
|
41a6c3 |
- if (rv != APR_SUCCESS)
|
|
|
41a6c3 |
- client_error = 1;
|
|
|
41a6c3 |
}
|
|
|
41a6c3 |
else if (cur->desc.s == client_socket) {
|
|
|
41a6c3 |
pollevent = cur->rtnevents;
|
|
|
41a6c3 |
- if (pollevent & APR_POLLIN) {
|
|
|
41a6c3 |
+ if (pollevent & (APR_POLLIN | APR_POLLHUP)) {
|
|
|
41a6c3 |
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02448)
|
|
|
41a6c3 |
"client was readable");
|
|
|
41a6c3 |
rv = proxy_wstunnel_transfer(r, c, backconn, bb, "client");
|
|
|
41a6c3 |
+ } else if (pollevent & APR_POLLERR) {
|
|
|
41a6c3 |
+ rv = APR_EPIPE;
|
|
|
41a6c3 |
+ c->aborted = 1;
|
|
|
41a6c3 |
+ ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(02607)
|
|
|
41a6c3 |
+ "error on client conn");
|
|
|
41a6c3 |
}
|
|
|
41a6c3 |
}
|
|
|
41a6c3 |
else {
|
|
|
41a6c3 |
@@ -294,9 +300,6 @@ static int ap_proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
|
|
|
41a6c3 |
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
|
|
|
41a6c3 |
"finished with poll() - cleaning up");
|
|
|
41a6c3 |
|
|
|
41a6c3 |
- if (client_error) {
|
|
|
41a6c3 |
- return HTTP_INTERNAL_SERVER_ERROR;
|
|
|
41a6c3 |
- }
|
|
|
41a6c3 |
return OK;
|
|
|
41a6c3 |
}
|
|
|
41a6c3 |
|