Skip to content

Commit

Permalink
*) mod_http2: connection terminology renamed to master/secondary.
Browse files Browse the repository at this point in the history
     trunk patch: http://svn.apache.org/r1878926
                  http://svn.apache.org/r1879156
     2.4.x patch: https://svn.apache.org/repos/asf/httpd/httpd/patches/2.4.x/h2-master-secondary.patch
     +1: icing, ylavic, minfrin
     ylavic: nitpicking, mixed "H2_secondary_IN" and "H2_secondary_OUT" case to
             register the filters, but not for adding them. IIRC filters names
             are case insentive so shouldn't matter, just popped at my eyes..
     icing: updated patch and added r1879156 to fix the eye bleed.
     jailletc36: CHANGES could also be looked at if it makes sense to update the terminology
                 also here


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1879642 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
minfrin committed Jul 8, 2020
1 parent 4a4960e commit 63a0a87
Show file tree
Hide file tree
Showing 16 changed files with 288 additions and 364 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
Changes with Apache 2.4.44

*) mod_http2: The module now handles master/secondary connections and has marked
methods according to use. [Stefan Eissing]

*) core: Drop an invalid Last-Modified header value coming
from a FCGI/CGI script instead of replacing it with Unix epoch.
[Luca Toscano]
Expand Down
11 changes: 0 additions & 11 deletions STATUS
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,6 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]

*) mod_http2: connection terminology renamed to master/secondary.
trunk patch: http://svn.apache.org/r1878926
http://svn.apache.org/r1879156
2.4.x patch: https://svn.apache.org/repos/asf/httpd/httpd/patches/2.4.x/h2-master-secondary.patch
+1: icing, ylavic, minfrin
ylavic: nitpicking, mixed "H2_secondary_IN" and "H2_secondary_OUT" case to
register the filters, but not for adding them. IIRC filters names
are case insentive so shouldn't matter, just popped at my eyes..
icing: updated patch and added r1879156 to fix the eye bleed.
jailletc36: CHANGES could also be looked at if it makes sense to update the terminology
also here

PATCHES PROPOSED TO BACKPORT FROM TRUNK:
[ New proposals should be added at the end of the list ]
Expand Down
52 changes: 26 additions & 26 deletions modules/http2/h2_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ apr_status_t h2_conn_child_init(apr_pool_t *pool, server_rec *s)
ap_register_input_filter("H2_IN", h2_filter_core_input,
NULL, AP_FTYPE_CONNECTION);

status = h2_mplx_child_init(pool, s);
status = h2_mplx_m_child_init(pool, s);

if (status == APR_SUCCESS) {
status = apr_socket_create(&dummy_socket, APR_INET, SOCK_STREAM,
Expand Down Expand Up @@ -266,7 +266,7 @@ apr_status_t h2_conn_pre_close(struct h2_ctx *ctx, conn_rec *c)
return DONE;
}

conn_rec *h2_slave_create(conn_rec *master, int slave_id, apr_pool_t *parent)
conn_rec *h2_secondary_create(conn_rec *master, int sec_id, apr_pool_t *parent)
{
apr_allocator_t *allocator;
apr_status_t status;
Expand All @@ -277,7 +277,7 @@ conn_rec *h2_slave_create(conn_rec *master, int slave_id, apr_pool_t *parent)

ap_assert(master);
ap_log_cerror(APLOG_MARK, APLOG_TRACE3, 0, master,
"h2_stream(%ld-%d): create slave", master->id, slave_id);
"h2_stream(%ld-%d): create secondary", master->id, sec_id);

/* We create a pool with its own allocator to be used for
* processing a request. This is the only way to have the processing
Expand All @@ -290,18 +290,18 @@ conn_rec *h2_slave_create(conn_rec *master, int slave_id, apr_pool_t *parent)
status = apr_pool_create_ex(&pool, parent, NULL, allocator);
if (status != APR_SUCCESS) {
ap_log_cerror(APLOG_MARK, APLOG_ERR, status, master,
APLOGNO(10004) "h2_session(%ld-%d): create slave pool",
master->id, slave_id);
APLOGNO(10004) "h2_session(%ld-%d): create secondary pool",
master->id, sec_id);
return NULL;
}
apr_allocator_owner_set(allocator, pool);
apr_pool_tag(pool, "h2_slave_conn");
apr_pool_tag(pool, "h2_secondary_conn");

c = (conn_rec *) apr_palloc(pool, sizeof(conn_rec));
if (c == NULL) {
ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_ENOMEM, master,
APLOGNO(02913) "h2_session(%ld-%d): create slave",
master->id, slave_id);
APLOGNO(02913) "h2_session(%ld-%d): create secondary",
master->id, sec_id);
apr_pool_destroy(pool);
return NULL;
}
Expand All @@ -328,58 +328,58 @@ conn_rec *h2_slave_create(conn_rec *master, int slave_id, apr_pool_t *parent)
c->clogging_input_filters = 1;
c->log = NULL;
c->log_id = apr_psprintf(pool, "%ld-%d",
master->id, slave_id);
master->id, sec_id);
c->aborted = 0;
/* We cannot install the master connection socket on the slaves, as
/* We cannot install the master connection socket on the secondary, as
* modules mess with timeouts/blocking of the socket, with
* unwanted side effects to the master connection processing.
* Fortunately, since we never use the slave socket, we can just install
* Fortunately, since we never use the secondary socket, we can just install
* a single, process-wide dummy and everyone is happy.
*/
ap_set_module_config(c->conn_config, &core_module, dummy_socket);
/* TODO: these should be unique to this thread */
c->sbh = master->sbh;
/* TODO: not all mpm modules have learned about slave connections yet.
* copy their config from master to slave.
/* TODO: not all mpm modules have learned about secondary connections yet.
* copy their config from master to secondary.
*/
if ((mpm = h2_conn_mpm_module()) != NULL) {
cfg = ap_get_module_config(master->conn_config, mpm);
ap_set_module_config(c->conn_config, mpm, cfg);
}

ap_log_cerror(APLOG_MARK, APLOG_TRACE3, 0, c,
"h2_slave(%s): created", c->log_id);
"h2_secondary(%s): created", c->log_id);
return c;
}

void h2_slave_destroy(conn_rec *slave)
void h2_secondary_destroy(conn_rec *secondary)
{
ap_log_cerror(APLOG_MARK, APLOG_TRACE3, 0, slave,
"h2_slave(%s): destroy", slave->log_id);
slave->sbh = NULL;
apr_pool_destroy(slave->pool);
ap_log_cerror(APLOG_MARK, APLOG_TRACE3, 0, secondary,
"h2_secondary(%s): destroy", secondary->log_id);
secondary->sbh = NULL;
apr_pool_destroy(secondary->pool);
}

apr_status_t h2_slave_run_pre_connection(conn_rec *slave, apr_socket_t *csd)
apr_status_t h2_secondary_run_pre_connection(conn_rec *secondary, apr_socket_t *csd)
{
if (slave->keepalives == 0) {
if (secondary->keepalives == 0) {
/* Simulate that we had already a request on this connection. Some
* hooks trigger special behaviour when keepalives is 0.
* (Not necessarily in pre_connection, but later. Set it here, so it
* is in place.) */
slave->keepalives = 1;
secondary->keepalives = 1;
/* We signal that this connection will be closed after the request.
* Which is true in that sense that we throw away all traffic data
* on this slave connection after each requests. Although we might
* on this secondary connection after each requests. Although we might
* reuse internal structures like memory pools.
* The wanted effect of this is that httpd does not try to clean up
* any dangling data on this connection when a request is done. Which
* is unnecessary on a h2 stream.
*/
slave->keepalive = AP_CONN_CLOSE;
return ap_run_pre_connection(slave, csd);
secondary->keepalive = AP_CONN_CLOSE;
return ap_run_pre_connection(secondary, csd);
}
ap_assert(slave->output_filters);
ap_assert(secondary->output_filters);
return APR_SUCCESS;
}

8 changes: 4 additions & 4 deletions modules/http2/h2_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ h2_mpm_type_t h2_conn_mpm_type(void);
const char *h2_conn_mpm_name(void);
int h2_mpm_supported(void);

conn_rec *h2_slave_create(conn_rec *master, int slave_id, apr_pool_t *parent);
void h2_slave_destroy(conn_rec *slave);
conn_rec *h2_secondary_create(conn_rec *master, int sec_id, apr_pool_t *parent);
void h2_secondary_destroy(conn_rec *secondary);

apr_status_t h2_slave_run_pre_connection(conn_rec *slave, apr_socket_t *csd);
void h2_slave_run_connection(conn_rec *slave);
apr_status_t h2_secondary_run_pre_connection(conn_rec *secondary, apr_socket_t *csd);
void h2_secondary_run_connection(conn_rec *secondary);

#endif /* defined(__mod_h2__h2_conn__) */
4 changes: 2 additions & 2 deletions modules/http2/h2_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ static void add_streams(apr_bucket_brigade *bb, h2_session *s, int last)
x.s = s;
x.idx = 0;
bbout(bb, " \"streams\": {");
h2_mplx_stream_do(s->mplx, add_stream, &x);
h2_mplx_m_stream_do(s->mplx, add_stream, &x);
bbout(bb, "\n }%s\n", last? "" : ",");
}

Expand Down Expand Up @@ -433,7 +433,7 @@ static void add_stats(apr_bucket_brigade *bb, h2_session *s,
static apr_status_t h2_status_insert(h2_task *task, apr_bucket *b)
{
h2_mplx *m = task->mplx;
h2_stream *stream = h2_mplx_stream_get(m, task->stream_id);
h2_stream *stream = h2_mplx_t_stream_get(m, task);
h2_session *s;
conn_rec *c;

Expand Down
10 changes: 5 additions & 5 deletions modules/http2/h2_h2.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ static int h2_h2_pre_close_conn(conn_rec *c)
{
h2_ctx *ctx;

/* slave connection? */
/* secondary connection? */
if (c->master) {
return DECLINED;
}
Expand Down Expand Up @@ -710,7 +710,7 @@ static void check_push(request_rec *r, const char *tag)

static int h2_h2_post_read_req(request_rec *r)
{
/* slave connection? */
/* secondary connection? */
if (r->connection->master) {
struct h2_task *task = h2_ctx_get_task(r->connection);
/* This hook will get called twice on internal redirects. Take care
Expand All @@ -729,7 +729,7 @@ static int h2_h2_post_read_req(request_rec *r)
ap_add_output_filter("H2_RESPONSE", task, r, r->connection);

for (f = r->input_filters; f; f = f->next) {
if (!strcmp("H2_SLAVE_IN", f->frec->name)) {
if (!strcmp("H2_SECONDARY_IN", f->frec->name)) {
f->r = r;
break;
}
Expand All @@ -743,15 +743,15 @@ static int h2_h2_post_read_req(request_rec *r)

static int h2_h2_late_fixups(request_rec *r)
{
/* slave connection? */
/* secondary connection? */
if (r->connection->master) {
struct h2_task *task = h2_ctx_get_task(r->connection);
if (task) {
/* check if we copy vs. setaside files in this location */
task->output.copy_files = h2_config_rgeti(r, H2_CONF_COPY_FILES);
if (task->output.copy_files) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, task->c,
"h2_slave_out(%s): copy_files on", task->id);
"h2_secondary_out(%s): copy_files on", task->id);
h2_beam_on_file_beam(task->output.beam, h2_beam_no_files, NULL);
}
check_push(r, "late_fixup");
Expand Down
Loading

0 comments on commit 63a0a87

Please sign in to comment.