Return-Path: X-Original-To: apmail-httpd-cvs-archive@www.apache.org Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E96F518A06 for ; Mon, 14 Dec 2015 11:09:36 +0000 (UTC) Received: (qmail 71964 invoked by uid 500); 14 Dec 2015 11:09:36 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 71898 invoked by uid 500); 14 Dec 2015 11:09:36 -0000 Mailing-List: contact cvs-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 cvs@httpd.apache.org Received: (qmail 71889 invoked by uid 99); 14 Dec 2015 11:09:36 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Dec 2015 11:09:36 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 5AF061A02CC for ; Mon, 14 Dec 2015 11:09:36 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.246 X-Spam-Level: * X-Spam-Status: No, score=1.246 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.554] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id JmvdNJqQGF9B for ; Mon, 14 Dec 2015 11:09:34 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id 5483F20C70 for ; Mon, 14 Dec 2015 11:09:33 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 4144CE04C1 for ; Mon, 14 Dec 2015 11:09:32 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 0F7FA3A0424 for ; Mon, 14 Dec 2015 11:09:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1719881 - in /httpd/httpd/trunk/modules/http2: h2_alt_svc.c h2_config.c h2_ctx.c h2_ctx.h h2_h2.c h2_switch.c h2_task.c Date: Mon, 14 Dec 2015 11:09:31 -0000 To: cvs@httpd.apache.org From: icing@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151214110932.0F7FA3A0424@svn01-us-west.apache.org> Author: icing Date: Mon Dec 14 11:09:31 2015 New Revision: 1719881 URL: http://svn.apache.org/viewvc?rev=1719881&view=rev Log: saving some bytes and cycles by not create h2_ctx for every connection and checking for c->master in the hooks Modified: httpd/httpd/trunk/modules/http2/h2_alt_svc.c httpd/httpd/trunk/modules/http2/h2_config.c httpd/httpd/trunk/modules/http2/h2_ctx.c httpd/httpd/trunk/modules/http2/h2_ctx.h httpd/httpd/trunk/modules/http2/h2_h2.c httpd/httpd/trunk/modules/http2/h2_switch.c httpd/httpd/trunk/modules/http2/h2_task.c Modified: httpd/httpd/trunk/modules/http2/h2_alt_svc.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_alt_svc.c?rev=1719881&r1=1719880&r2=1719881&view=diff ============================================================================== --- httpd/httpd/trunk/modules/http2/h2_alt_svc.c (original) +++ httpd/httpd/trunk/modules/http2/h2_alt_svc.c Mon Dec 14 11:09:31 2015 @@ -73,7 +73,6 @@ h2_alt_svc *h2_alt_svc_parse(const char static int h2_alt_svc_handler(request_rec *r) { - h2_ctx *ctx; const h2_config *cfg; int i; @@ -82,8 +81,7 @@ static int h2_alt_svc_handler(request_re return DECLINED; } - ctx = h2_ctx_rget(r); - if (h2_ctx_is_active(ctx) || h2_ctx_is_task(ctx)) { + if (h2_ctx_rget(r)) { return DECLINED; } Modified: httpd/httpd/trunk/modules/http2/h2_config.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_config.c?rev=1719881&r1=1719880&r2=1719881&view=diff ============================================================================== --- httpd/httpd/trunk/modules/http2/h2_config.c (original) +++ httpd/httpd/trunk/modules/http2/h2_config.c Mon Dec 14 11:09:31 2015 @@ -561,14 +561,16 @@ const h2_config *h2_config_rget(request_ const h2_config *h2_config_get(conn_rec *c) { - h2_ctx *ctx = h2_ctx_get(c); + h2_ctx *ctx = h2_ctx_get(c, 0); - if (ctx->config) { - return ctx->config; - } - else if (ctx->server) { - ctx->config = h2_config_sget(ctx->server); - return ctx->config; + if (ctx) { + if (ctx->config) { + return ctx->config; + } + else if (ctx->server) { + ctx->config = h2_config_sget(ctx->server); + return ctx->config; + } } return h2_config_sget(c->base_server); Modified: httpd/httpd/trunk/modules/http2/h2_ctx.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_ctx.c?rev=1719881&r1=1719880&r2=1719881&view=diff ============================================================================== --- httpd/httpd/trunk/modules/http2/h2_ctx.c (original) +++ httpd/httpd/trunk/modules/http2/h2_ctx.c Mon Dec 14 11:09:31 2015 @@ -20,6 +20,7 @@ #include #include "h2_private.h" +#include "h2_session.h" #include "h2_task.h" #include "h2_ctx.h" #include "h2_private.h" @@ -41,10 +42,10 @@ h2_ctx *h2_ctx_create_for(const conn_rec return ctx; } -h2_ctx *h2_ctx_get(const conn_rec *c) +h2_ctx *h2_ctx_get(const conn_rec *c, int create) { h2_ctx *ctx = (h2_ctx*)ap_get_module_config(c->conn_config, &http2_module); - if (ctx == NULL) { + if (ctx == NULL && create) { ctx = h2_ctx_create(c); } return ctx; @@ -52,7 +53,7 @@ h2_ctx *h2_ctx_get(const conn_rec *c) h2_ctx *h2_ctx_rget(const request_rec *r) { - return h2_ctx_get(r->connection); + return h2_ctx_get(r->connection, 0); } const char *h2_ctx_protocol_get(const conn_rec *c) @@ -64,10 +65,19 @@ const char *h2_ctx_protocol_get(const co h2_ctx *h2_ctx_protocol_set(h2_ctx *ctx, const char *proto) { ctx->protocol = proto; - ctx->is_h2 = (proto != NULL); return ctx; } +h2_session *h2_ctx_session_get(h2_ctx *ctx) +{ + return ctx? ctx->session : NULL; +} + +void h2_ctx_session_set(h2_ctx *ctx, struct h2_session *session) +{ + ctx->session = session; +} + h2_ctx *h2_ctx_server_set(h2_ctx *ctx, server_rec *s) { ctx->server = s; @@ -79,12 +89,7 @@ int h2_ctx_is_task(h2_ctx *ctx) return ctx && !!ctx->task; } -int h2_ctx_is_active(h2_ctx *ctx) -{ - return ctx && ctx->is_h2; -} - struct h2_task *h2_ctx_get_task(h2_ctx *ctx) { - return ctx->task; + return ctx? ctx->task : NULL; } Modified: httpd/httpd/trunk/modules/http2/h2_ctx.h URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_ctx.h?rev=1719881&r1=1719880&r2=1719881&view=diff ============================================================================== --- httpd/httpd/trunk/modules/http2/h2_ctx.h (original) +++ httpd/httpd/trunk/modules/http2/h2_ctx.h Mon Dec 14 11:09:31 2015 @@ -16,6 +16,7 @@ #ifndef __mod_h2__h2_ctx__ #define __mod_h2__h2_ctx__ +struct h2_session; struct h2_task; struct h2_config; @@ -28,15 +29,22 @@ struct h2_config; * - those created by ourself to perform work on HTTP/2 streams */ typedef struct h2_ctx { - int is_h2; /* h2 engine is used */ const char *protocol; /* the protocol negotiated */ + struct h2_session *session; /* the session established */ struct h2_task *task; /* the h2_task executing or NULL */ const char *hostname; /* hostname negotiated via SNI, optional */ server_rec *server; /* httpd server config selected. */ const struct h2_config *config; /* effective config in this context */ } h2_ctx; -h2_ctx *h2_ctx_get(const conn_rec *c); +/** + * Get (or create) a h2 context record for this connection. + * @param c the connection to look at + * @param create != 0 iff missing context shall be created + * @return h2 context of this connection + */ +h2_ctx *h2_ctx_get(const conn_rec *c, int create); + h2_ctx *h2_ctx_rget(const request_rec *r); h2_ctx *h2_ctx_create_for(const conn_rec *c, struct h2_task *task); @@ -50,13 +58,15 @@ h2_ctx *h2_ctx_protocol_set(h2_ctx *ctx, */ h2_ctx *h2_ctx_server_set(h2_ctx *ctx, server_rec *s); +struct h2_session *h2_ctx_session_get(h2_ctx *ctx); +void h2_ctx_session_set(h2_ctx *ctx, struct h2_session *session); + /** * Get the h2 protocol negotiated for this connection, or NULL. */ const char *h2_ctx_protocol_get(const conn_rec *c); int h2_ctx_is_task(h2_ctx *ctx); -int h2_ctx_is_active(h2_ctx *ctx); struct h2_task *h2_ctx_get_task(h2_ctx *ctx); Modified: httpd/httpd/trunk/modules/http2/h2_h2.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_h2.c?rev=1719881&r1=1719880&r2=1719881&view=diff ============================================================================== --- httpd/httpd/trunk/modules/http2/h2_h2.c (original) +++ httpd/httpd/trunk/modules/http2/h2_h2.c Mon Dec 14 11:09:31 2015 @@ -574,8 +574,13 @@ void h2_h2_register_hooks(void) int h2_h2_process_conn(conn_rec* c) { - h2_ctx *ctx = h2_ctx_get(c); + h2_ctx *ctx; + if (c->master) { + return DECLINED; + } + + ctx = h2_ctx_get(c, 0); ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c, "h2_h2, process_conn"); if (h2_ctx_is_task(ctx)) { /* our stream pseudo connection */ @@ -612,6 +617,9 @@ int h2_h2_process_conn(conn_rec* c) if ((slen >= 24) && !memcmp(H2_MAGIC_TOKEN, s, 24)) { ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c, "h2_h2, direct mode detected"); + if (!ctx) { + ctx = h2_ctx_get(c, 1); + } h2_ctx_protocol_set(ctx, h2_h2_is_tls(c)? "h2" : "h2c"); } else { @@ -630,7 +638,7 @@ int h2_h2_process_conn(conn_rec* c) /* If "h2" was selected as protocol (by whatever mechanism), take over * the connection. */ - if (h2_ctx_is_active(ctx)) { + if (ctx) { ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c, "h2_h2, connection, h2 active"); Modified: httpd/httpd/trunk/modules/http2/h2_switch.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_switch.c?rev=1719881&r1=1719880&r2=1719881&view=diff ============================================================================== --- httpd/httpd/trunk/modules/http2/h2_switch.c (original) +++ httpd/httpd/trunk/modules/http2/h2_switch.c Mon Dec 14 11:09:31 2015 @@ -136,7 +136,7 @@ static int h2_protocol_switch(conn_rec * } if (found) { - h2_ctx *ctx = h2_ctx_get(c); + h2_ctx *ctx = h2_ctx_get(c, 1); ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c, "switching protocol to '%s'", protocol); Modified: httpd/httpd/trunk/modules/http2/h2_task.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http2/h2_task.c?rev=1719881&r1=1719880&r2=1719881&view=diff ============================================================================== --- httpd/httpd/trunk/modules/http2/h2_task.c (original) +++ httpd/httpd/trunk/modules/http2/h2_task.c Mon Dec 14 11:09:31 2015 @@ -118,8 +118,13 @@ void h2_task_register_hooks(void) static int h2_task_pre_conn(conn_rec* c, void *arg) { - h2_ctx *ctx = h2_ctx_get(c); + h2_ctx *ctx; + if (!c->master) { + return OK; + } + + ctx = h2_ctx_get(c, 0); (void)arg; if (h2_ctx_is_task(ctx)) { h2_task *task = h2_ctx_get_task(ctx); @@ -246,8 +251,13 @@ static apr_status_t h2_task_process_requ static int h2_task_process_conn(conn_rec* c) { - h2_ctx *ctx = h2_ctx_get(c); + h2_ctx *ctx; + + if (!c->master) { + return DECLINED; + } + ctx = h2_ctx_get(c, 0); if (h2_ctx_is_task(ctx)) { if (!ctx->task->serialize_headers) { ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, c,