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