Return-Path: X-Original-To: apmail-httpd-dev-archive@www.apache.org Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 318C418B73 for ; Fri, 29 Jan 2016 13:02:03 +0000 (UTC) Received: (qmail 12336 invoked by uid 500); 29 Jan 2016 13:01:46 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 12258 invoked by uid 500); 29 Jan 2016 13:01:46 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 12248 invoked by uid 99); 29 Jan 2016 13:01:46 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Jan 2016 13:01:46 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 6E17BC1303 for ; Fri, 29 Jan 2016 13:01:46 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.101 X-Spam-Level: X-Spam-Status: No, score=-0.101 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RP_MATCHES_RCVD=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=greenbytes.de header.b=hWOc93d3; dkim=pass (1024-bit key) header.d=greenbytes.de header.b=hWOc93d3 Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id PNvMX3rwrk1b for ; Fri, 29 Jan 2016 13:01:41 +0000 (UTC) Received: from mail.greenbytes.de (mail.greenbytes.de [217.91.35.233]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 364892050B for ; Fri, 29 Jan 2016 13:01:41 +0000 (UTC) Received: by mail.greenbytes.de (Postfix, from userid 117) id 6902B15A0729; Fri, 29 Jan 2016 14:01:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=greenbytes.de; s=mail; t=1454072492; bh=8EjW22EYADfTeR6uFAuZaneeME2KMOzNZKIhOT66WKs=; h=From:Subject:Date:To:From; b=hWOc93d3Bk5v/pXsG+42l47ZNuI7yjfF7HF8K3QGEP1UM6Z04b0a2MGYpqeeyY3tP 2tn0cFqx2yHIGc7fo/p+HHlRlz9lnfkjoG1QV9r0vOF/vdXkX5zb927tRJGbf+p/Ie Mt3NL9cWPa3XnoivqmMceqRwK7SGQIa0F8HkEMnU= Received: from [192.168.1.48] (unknown [87.78.31.144]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mail.greenbytes.de (Postfix) with ESMTPSA id 1693F15A008E for ; Fri, 29 Jan 2016 14:01:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=greenbytes.de; s=mail; t=1454072492; bh=8EjW22EYADfTeR6uFAuZaneeME2KMOzNZKIhOT66WKs=; h=From:Subject:Date:To:From; b=hWOc93d3Bk5v/pXsG+42l47ZNuI7yjfF7HF8K3QGEP1UM6Z04b0a2MGYpqeeyY3tP 2tn0cFqx2yHIGc7fo/p+HHlRlz9lnfkjoG1QV9r0vOF/vdXkX5zb927tRJGbf+p/Ie Mt3NL9cWPa3XnoivqmMceqRwK7SGQIa0F8HkEMnU= From: Stefan Eissing Content-Type: multipart/mixed; boundary="Apple-Mail=_6CB0B781-9F8C-4721-A5CC-48EBE09BDCB0" Subject: event mpm and slave connections Message-Id: Date: Fri, 29 Jan 2016 14:01:30 +0100 To: dev@httpd.apache.org Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) X-Mailer: Apple Mail (2.3112) --Apple-Mail=_6CB0B781-9F8C-4721-A5CC-48EBE09BDCB0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii I would like to propose some additions to event that help me get rid of = two ugly hacks in mod_http2: 1. Initialization of slave connections event registers on pre_connection hook and checks if c is a slave = (c->master) and if the connection state is either not there or the same = as master (pointer copy). It then sets up a new cs using the slave = connection pool. 2. Initialization of server config event keeps in its private connection state parts the server = configuration (queues for timeouts and keepalives) that are unique to = each server because of Timeout and KeepAliveTimeout settings. Normally, = theses are set on post_read_request hooks which is fine and well. On = master connections however, these hooks may never get called so the = server config remains stuck on the connections base server. In the case of SNI however, we know which server this connection is = intended for and should use its Timeouts. This is done by installing an = early protocol_switch hook that sees connections updates and server_rec = and initializes its connection state accordingly. Please vote on the attached patch. I do not want to mess with event = without having some moral backup... -Stefan --Apple-Mail=_6CB0B781-9F8C-4721-A5CC-48EBE09BDCB0 Content-Disposition: attachment; filename=event_fix_slaves.patch Content-Type: application/octet-stream; name="event_fix_slaves.patch" Content-Transfer-Encoding: 7bit Index: server/mpm/event/event.c =================================================================== --- server/mpm/event/event.c (revision 1727544) +++ server/mpm/event/event.c (working copy) @@ -3293,6 +3293,55 @@ return OK; } +static void setup_slave_conn(conn_rec *c, void *csd) +{ + event_conn_state_t *mcs; + event_conn_state_t *cs; + + mcs = ap_get_module_config(c->master->conn_config, &mpm_event_module); + + cs = apr_pcalloc(c->pool, sizeof(*cs)); + cs->c = c; + cs->r = NULL; + cs->sc = mcs->sc; + cs->suspended = 0; + cs->p = c->pool; + cs->bucket_alloc = c->bucket_alloc; + cs->pfd = mcs->pfd; + cs->pub = mcs->pub; + cs->pub.state = CONN_STATE_READ_REQUEST_LINE; + cs->pub.sense = CONN_SENSE_DEFAULT; + + c->cs = &(cs->pub); + ap_set_module_config(c->conn_config, &mpm_event_module, cs); +} + +static int event_pre_connection(conn_rec *c, void *csd) +{ + if (c->master && (!c->cs || c->cs == c->master->cs)) { + setup_slave_conn(c, csd); + } + return OK; +} + +static int event_protocol_switch(conn_rec *c, request_rec *r, server_rec *s, + const char *protocol) +{ + if (!r && s) { + /* connection based switching of protocol, set the correct server + * configuration, so that timeouts, keepalives and such are used + * for the server that the connection was switched on. + * Normally, we set this on post_read_request, but on a protocol + * other than http/1.1, this might never happen. + */ + event_conn_state_t *cs; + + cs = ap_get_module_config(c->conn_config, &mpm_event_module); + cs->sc = ap_get_module_config(s->module_config, &mpm_event_module); + } + return DECLINED; +} + /* This really should be a post_config hook, but the error log is already * redirected by that point, so we need to do this in the open_logs phase. */ @@ -3791,6 +3840,9 @@ ap_hook_post_read_request(event_post_read_request, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_get_name(event_get_name, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_mpm_resume_suspended(event_resume_suspended, NULL, NULL, APR_HOOK_MIDDLE); + + ap_hook_pre_connection(event_pre_connection, NULL, NULL, APR_HOOK_REALLY_FIRST); + ap_hook_protocol_switch(event_protocol_switch, NULL, NULL, APR_HOOK_REALLY_FIRST); } static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, --Apple-Mail=_6CB0B781-9F8C-4721-A5CC-48EBE09BDCB0--