From: Stefan Eissing Date: Tue, 19 Jan 2016 15:24:41 +0000 (+0000) Subject: checking for stopping MPM before going into blocking keepalive read X-Git-Tag: 2.5.0-alpha~2364 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11e47dd8f02b37a2e4b96eeb045ea0ae6c10e107;p=thirdparty%2Fapache%2Fhttpd.git checking for stopping MPM before going into blocking keepalive read git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1725543 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http2/h2_push.c b/modules/http2/h2_push.c index d69c1e718c8..717865c5aca 100644 --- a/modules/http2/h2_push.c +++ b/modules/http2/h2_push.c @@ -466,6 +466,28 @@ void h2_push_policy_determine(struct h2_request *req, apr_pool_t *p, int push_en /******************************************************************************* * push diary + * + * - The push diary keeps track of resources already PUSHed via HTTP/2 on this + * connection. It records a hash value from the absolute URL of the resource + * pushed. + * - Lacking openssl, it uses 'apr_hashfunc_default' for the value + * - with openssl, it uses SHA256 to calculate the hash value + * - whatever the method to generate the hash, the diary keeps a maximum of 64 + * bits per hash, limiting the memory consumption to about + * H2PushDiarySize * 8 + * bytes. Entries are sorted by most recently used and oldest entries are + * forgotten first. + * - Clients can initialize/replace the push diary by sending a 'Cache-Digest' + * header. Currently, this is the base64url encoded value of the cache digest + * as specified in https://datatracker.ietf.org/doc/draft-kazuho-h2-cache-digest/ + * This draft can be expected to evolve and the definition of the header + * will be added there and refined. + * - The cache digest header is a Golomb Coded Set of hash values, but it may + * limit the amount of bits per hash value even further. For a good description + * of GCS, read here: + * http://giovanni.bajo.it/post/47119962313/golomb-coded-sets-smaller-than-bloom-filters + * - The means that the push diary might be initialized with hash values of much + * less than 64 bits, leading to more false positives, but smaller digest size. ******************************************************************************/ diff --git a/modules/http2/h2_session.c b/modules/http2/h2_session.c index b0100fa70fc..94f637d2c13 100644 --- a/modules/http2/h2_session.c +++ b/modules/http2/h2_session.c @@ -18,6 +18,8 @@ #include #include +#include + #include #include #include @@ -1957,7 +1959,7 @@ apr_status_t h2_session_process(h2_session *session, int async) { apr_status_t status = APR_SUCCESS; conn_rec *c = session->c; - int rv, have_written, have_read; + int rv, have_written, have_read, mpm_state; ap_log_cerror( APLOG_MARK, APLOG_TRACE1, status, c, "h2_session(%ld): process start, async=%d", session->id, async); @@ -1986,6 +1988,20 @@ apr_status_t h2_session_process(h2_session *session, int async) break; case H2_SESSION_ST_IDLE: + if ((status = ap_mpm_query(AP_MPMQ_MPM_STATE, &mpm_state))) { + goto out; + } + if (mpm_state == AP_MPMQ_STOPPING) { + dispatch_event(session, H2_SESSION_EV_CONN_TIMEOUT, 0, NULL); + break; + } + /* We'd like to wait in smaller increments, using a 1 second + * timeout maybe, trying n times. That would allow us to exit + * on MPMQ_STOPPING earlier. + * Unfortunately, once a socket timeout happened, SSL reports + * EOF on reads and the connection is gone. Not sure if we can + * avoid that... + */ h2_filter_cin_timeout_set(session->cin, session->keepalive_secs); ap_update_child_status(c->sbh, SERVER_BUSY_KEEPALIVE, NULL); status = h2_session_read(session, 1, 10); @@ -1998,7 +2014,6 @@ apr_status_t h2_session_process(h2_session *session, int async) } else if (APR_STATUS_IS_TIMEUP(status)) { dispatch_event(session, H2_SESSION_EV_CONN_TIMEOUT, 0, NULL); - break; } else { dispatch_event(session, H2_SESSION_EV_CONN_ERROR, 0, NULL);