ASF Bugzilla – Attachment 15375 Details for
Bug 35292
ap_lingering_close does not linger up to MAX_SECS_TO_LINGER
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Second attempt. Patch against http-2.0.x
apacheconn2.patch (text/plain), 2.62 KB, created by
Gonzalo Paniagua Javier
on 2005-06-11 20:37:13 UTC
(
hide
)
Description:
Second attempt. Patch against http-2.0.x
Filename:
MIME Type:
Creator:
Gonzalo Paniagua Javier
Created:
2005-06-11 20:37:13 UTC
Size:
2.62 KB
patch
obsolete
>Index: connection.c >=================================================================== >--- connection.c (revision 190159) >+++ connection.c (working copy) >@@ -94,14 +94,14 @@ > * TCP RST packets to be sent which can tear down a connection before > * all the response data has been sent to the client. > */ >-#define SECONDS_TO_LINGER 2 >+#define MAX_READS_LINGER 30 >+#define GRACE_PERIOD apr_time_make (0, 500000) > AP_DECLARE(void) ap_lingering_close(conn_rec *c) > { > char dummybuf[512]; > apr_size_t nbytes = sizeof(dummybuf); > apr_status_t rc; >- apr_int32_t timeout; >- apr_int32_t total_linger_time = 0; >+ apr_int32_t nread_ops; > apr_socket_t *csd = ap_get_module_config(c->conn_config, &core_module); > > if (!csd) { >@@ -132,30 +132,33 @@ > /* Shut down the socket for write, which will send a FIN > * to the peer. > */ >- if (apr_shutdown(csd, APR_SHUTDOWN_WRITE) != APR_SUCCESS >+ if (apr_socket_shutdown(csd, APR_SHUTDOWN_WRITE) != APR_SUCCESS > || c->aborted) { > apr_socket_close(csd); > return; > } > >- /* Read all data from the peer until we reach "end-of-file" (FIN >- * from peer) or we've exceeded our overall timeout. If the client does >- * not send us bytes within 2 seconds (a value pulled from Apache 1.3 >- * which seems to work well), close the connection. >+ /* Read pending input from the peer. If the first read attempt >+ * is succcessful, it reads up to MAX_READS_LINGER times or >+ * until the read blocks for more than GRACE_PERIOD, whichever >+ * happens first. >+ * So in the worst case this can take: >+ * MAX_SECS_TO_LINGER + GRACE_PERIOD * (MAX_READS_LINGER - 1) >+ * which 30 + 0.5 * 29 = 44.5s. > */ >- timeout = apr_time_from_sec(SECONDS_TO_LINGER); >- apr_socket_timeout_set(csd, timeout); >+ apr_socket_timeout_set(csd, apr_time_from_sec(MAX_SECS_TO_LINGER)); > apr_socket_opt_set(csd, APR_INCOMPLETE_READ, 1); >- while (1) { >- nbytes = sizeof(dummybuf); >- rc = apr_recv(csd, dummybuf, &nbytes); >- if (rc != APR_SUCCESS || nbytes == 0) >- break; > >- total_linger_time += SECONDS_TO_LINGER; >- if (total_linger_time >= MAX_SECS_TO_LINGER) { >- break; >- } >+ rc = apr_socket_recv(csd, dummybuf, &nbytes); >+ if (rc == APR_SUCCESS && nbytes != 0) { >+ nread_ops = 1; >+ apr_socket_timeout_set(csd, GRACE_PERIOD); >+ while (nread_ops < MAX_READS_LINGER) { >+ nbytes = sizeof(dummybuf); >+ rc = apr_socket_recv(csd, dummybuf, &nbytes); >+ if (rc != APR_SUCCESS || nbytes == 0) >+ break; >+ } > } > > apr_socket_close(csd);
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 Raw
Actions:
View
Attachments on
bug 35292
:
15353
| 15375