ASF Bugzilla – Attachment 35443 Details for
Bug 61616
mod_proxy_connect: stall and connection loss on bi-directional traffic
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
suppress poll with long timeout in filter code (v2)
apache2-fix-ontop-of-v5.diff (text/plain), 8.08 KB, created by
Carsten Wolff
on 2017-10-19 15:28:18 UTC
(
hide
)
Description:
suppress poll with long timeout in filter code (v2)
Filename:
MIME Type:
Creator:
Carsten Wolff
Created:
2017-10-19 15:28:18 UTC
Size:
8.08 KB
patch
obsolete
>diff --git a/modules/proxy/mod_proxy_connect.c b/modules/proxy/mod_proxy_connect.c >index 0f7a465..63b26ab 100644 >--- a/modules/proxy/mod_proxy_connect.c >+++ b/modules/proxy/mod_proxy_connect.c >@@ -20,6 +20,7 @@ > #include "apr_poll.h" > > #define CONN_BLKSZ AP_IOBUFSIZE >+#define PROXY_WTO 50 > > module AP_MODULE_DECLARE_DATA proxy_connect_module; > >@@ -417,39 +418,41 @@ static int proxy_connect_handler(request_rec *r, proxy_worker *worker, > > if (cur->desc.s == backend.pfd.desc.s) { > pollevent = cur->rtnevents; >- if (pollevent & (APR_POLLIN | APR_POLLHUP)) { >+ if (pollevent & (APR_POLLIN | APR_POLLHUP) && >+ !client.c->data_in_output_filters) { > #ifdef DEBUGGING > ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01025) > "backend was readable"); > #endif >+ apr_socket_timeout_set(client.pfd.desc.s, PROXY_WTO); > rv = ap_proxy_transfer_between_connections(r, > backend.c, client.c, > backend.bb, client.bb, > "backend", NULL, CONN_BLKSZ, > AP_PROXY_TRANSFER_FLUSH_NEVER); >- if (rv == APR_SUCCESS >- && client.c->data_in_output_filters) { >+ apr_socket_timeout_set(client.pfd.desc.s, client.timeout); >+ if ( rv == APR_SUCCESS && client.c->data_in_output_filters ) >+ { > apr_pollset_remove(pollset, &client.pfd); >- client.pfd.reqevents = APR_POLLOUT; >+ client.pfd.reqevents = APR_POLLOUT | APR_POLLIN | >+ APR_POLLHUP; > apr_pollset_add(pollset, &client.pfd); >- if (backend.pfd.reqevents & APR_POLLIN) { >- apr_pollset_remove(pollset, &backend.pfd); >- } > } >- done |= rv != APR_SUCCESS; >+ if ( rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv) ) >+ done = 1; > } > else if (pollevent & APR_POLLOUT) { >- rv = client.core_output(client.core_filter, NULL); >- if (rv == APR_SUCCESS >- && !client.c->data_in_output_filters) { >- apr_pollset_remove(pollset, &client.pfd); >- client.pfd.reqevents = APR_POLLIN | APR_POLLHUP; >- apr_pollset_add(pollset, &client.pfd); >- if (backend.pfd.reqevents & APR_POLLIN) { >- apr_pollset_add(pollset, &backend.pfd); >- } >+ apr_socket_timeout_set(backend.pfd.desc.s, PROXY_WTO); >+ rv = backend.core_output(backend.core_filter, NULL); >+ apr_socket_timeout_set(backend.pfd.desc.s, backend.timeout); >+ if (rv == APR_SUCCESS && !backend.c->data_in_output_filters) >+ { >+ apr_pollset_remove(pollset, &backend.pfd); >+ backend.pfd.reqevents = APR_POLLIN | APR_POLLHUP; >+ apr_pollset_add(pollset, &backend.pfd); > } >- done |= rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv); >+ if ( rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv) ) >+ done = 1; > } > else if (pollevent & APR_POLLERR) { > ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(01026) >@@ -460,39 +463,41 @@ static int proxy_connect_handler(request_rec *r, proxy_worker *worker, > } > else if (cur->desc.s == client.pfd.desc.s) { > pollevent = cur->rtnevents; >- if (pollevent & (APR_POLLIN | APR_POLLHUP)) { >+ if (pollevent & (APR_POLLIN | APR_POLLHUP) && >+ !backend.c->data_in_output_filters) { > #ifdef DEBUGGING > ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01027) > "client was readable"); > #endif >+ apr_socket_timeout_set(backend.pfd.desc.s, PROXY_WTO); > rv = ap_proxy_transfer_between_connections(r, > client.c, backend.c, > client.bb, backend.bb, > "client", NULL, CONN_BLKSZ, > AP_PROXY_TRANSFER_FLUSH_NEVER); >- if (rv == APR_SUCCESS >- && backend.c->data_in_output_filters) { >+ apr_socket_timeout_set(backend.pfd.desc.s, backend.timeout); >+ if ( rv == APR_SUCCESS && backend.c->data_in_output_filters) >+ { > apr_pollset_remove(pollset, &backend.pfd); >- backend.pfd.reqevents = APR_POLLOUT; >+ backend.pfd.reqevents = APR_POLLOUT | APR_POLLIN | >+ APR_POLLHUP; > apr_pollset_add(pollset, &backend.pfd); >- if (client.pfd.reqevents & APR_POLLIN) { >- apr_pollset_remove(pollset, &client.pfd); >- } > } >- done |= rv != APR_SUCCESS; >+ if ( rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv) ) >+ done = 1; > } > else if (pollevent & APR_POLLOUT) { >- rv = backend.core_output(backend.core_filter, NULL); >- if (rv == APR_SUCCESS >- && !backend.c->data_in_output_filters) { >- apr_pollset_remove(pollset, &backend.pfd); >- backend.pfd.reqevents = APR_POLLIN | APR_POLLHUP; >- apr_pollset_add(pollset, &backend.pfd); >- if (client.pfd.reqevents & APR_POLLIN) { >- apr_pollset_add(pollset, &client.pfd); >- } >+ apr_socket_timeout_set(client.pfd.desc.s, PROXY_WTO); >+ rv = client.core_output(client.core_filter, NULL); >+ apr_socket_timeout_set(client.pfd.desc.s, client.timeout); >+ if (rv == APR_SUCCESS && !client.c->data_in_output_filters) >+ { >+ apr_pollset_remove(pollset, &client.pfd); >+ client.pfd.reqevents = APR_POLLIN | APR_POLLHUP; >+ apr_pollset_add(pollset, &client.pfd); > } >- done |= rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv); >+ if ( rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv) ) >+ done = 1; > } > else if (pollevent & APR_POLLERR) { > ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r, APLOGNO(02827) >diff --git a/server/core_filters.c b/server/core_filters.c >index 91d53f1..4f18333 100644 >--- a/server/core_filters.c >+++ b/server/core_filters.c >@@ -805,6 +805,14 @@ static apr_status_t send_brigade_blocking(apr_socket_t *s, > apr_socket_timeout_get(s, &timeout); > do { > rv = apr_poll(&pollset, 1, &nsds, timeout); >+ if ( timeout < 1000 && APR_STATUS_IS_TIMEUP(rv) ) { >+ ap_log_cerror(APLOG_MARK, APLOG_TRACE1, rv, c, >+ "send_brigade_blocking: TIMEUP on small " >+ "timeout (%ld), returning APR_INCOMPLETE", >+ timeout); >+ rv = APR_INCOMPLETE; >+ goto out; >+ } > } while (APR_STATUS_IS_EINTR(rv)); > if (rv == APR_SUCCESS) { > continue; >@@ -813,6 +821,7 @@ static apr_status_t send_brigade_blocking(apr_socket_t *s, > break; > } > } >+out: > return rv; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 61616
:
35421
|
35422
|
35423
|
35424
|
35425
|
35426
|
35427
|
35429
|
35430
|
35431
|
35432
|
35442
|
35443
|
35446
|
35447
|
35512
|
35513
|
35620
|
35621
|
35623
|
35639
|
35737
|
35738
|
35739
|
35772
|
35774
|
35776
|
35783
|
35784
|
35786
|
35787
|
35789