/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/
if (ap_mpm_query(AP_MPMQ_IS_ASYNC, &async_mpm)) { /* some MPMs do not implemnent this */
async_mpm = 0;
} #ifdef AP_MPMQ_CAN_WAITIO if (!async_mpm || ap_mpm_query(AP_MPMQ_CAN_WAITIO, &mpm_can_waitio)) {
mpm_can_waitio = 0;
} #endif
ctx = h2_conn_ctx_get(c);
ap_assert(ctx);
h2_conn_ctx_assign_session(ctx, session); /* remove the input filter of mod_reqtimeout, now that the connection * is established and we have switched to h2. reqtimeout has supervised * possibly configured handshake timeouts and needs to get out of the way
* now since the rest of its state handling assumes http/1.x to take place. */
ap_remove_input_filter_byhandle(c->input_filters, "reqtimeout");
cleanup: return rv;
}
int h2_c1_run(conn_rec *c)
{
apr_status_t status; int mpm_state = 0, keepalive = 0;
h2_conn_ctx_t *conn_ctx = h2_conn_ctx_get(c);
ap_assert(conn_ctx);
ap_assert(conn_ctx->session);
c->clogging_input_filters = 0; do { if (c->cs) {
c->cs->state = CONN_STATE_HANDLER;
}
if (ap_mpm_query(AP_MPMQ_MPM_STATE, &mpm_state)) { break;
}
} while (!async_mpm
&& c->keepalive == AP_CONN_KEEPALIVE
&& mpm_state != AP_MPMQ_STOPPING);
if (c->cs) { switch (conn_ctx->session->state) { case H2_SESSION_ST_INIT: case H2_SESSION_ST_IDLE: case H2_SESSION_ST_BUSY: case H2_SESSION_ST_WAIT: if (keepalive) { /* Flush then keep-alive */
c->cs->sense = CONN_SENSE_DEFAULT;
c->cs->state = CONN_STATE_WRITE_COMPLETION;
} else { /* Let the MPM know that we are not done and want to wait * for read using Timeout instead of KeepAliveTimeout. * See PR 63534.
*/
c->cs->sense = CONN_SENSE_WANT_READ; #ifdef AP_MPMQ_CAN_WAITIO if (mpm_can_waitio) { /* This tells the MPM to wait for the connection to be * readable (CONN_SENSE_WANT_READ) within the configured * Timeout and then come back to the process_connection() * hooks again when ready.
*/
c->cs->state = CONN_STATE_ASYNC_WAITIO;
} else #endif
{ /* This is a compat workaround to do the same using the * CONN_STATE_WRITE_COMPLETION state but with both * CONN_SENSE_WANT_READ to wait for readability rather * than writing and c->clogging_input_filters to force * reentering the process_connection() hooks from any * state when ready. This somehow will use Timeout too.
*/
c->cs->state = CONN_STATE_WRITE_COMPLETION;
c->clogging_input_filters = 1;
}
} break;
case H2_SESSION_ST_CLEANUP: case H2_SESSION_ST_DONE: default:
c->cs->state = CONN_STATE_LINGER; break;
}
}
if (APLOGctrace1(c)) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c, "h2_h2, process_conn, " "new connection using protocol '%s', direct=%d, " "tls acceptable=%d", proto, h2_c1_allows_direct(c),
h2_protocol_is_acceptable_c1(c, NULL, 1));
}
if (!strcmp(AP_PROTOCOL_HTTP1, proto)
&& h2_c1_allows_direct(c)
&& h2_protocol_is_acceptable_c1(c, NULL, 1)) { /* Fresh connection still is on http/1.1 and H2Direct is enabled. * Otherwise connection is in a fully acceptable state. * -> peek at the first 24 incoming bytes
*/
apr_bucket_brigade *temp; char *peek = NULL;
apr_size_t peeklen;
/* secondary connection? */ if (c->master) { return DECLINED;
}
ctx = h2_conn_ctx_get(c); if (ctx) { /* If the session has been closed correctly already, we will not * find a h2_conn_ctx_there. The presence indicates that the session
* is still ongoing. */ return h2_c1_pre_close(ctx, c);
} return DECLINED;
}
void h2_c1_register_hooks(void)
{ /* Our main processing needs to run quite late. Definitely after mod_ssl, * as we need its connection filters, but also before reqtimeout as its * method of timeouts is specific to HTTP/1.1 (as of now). * The core HTTP/1 processing run as REALLY_LAST, so we will have * a chance to take over before it.
*/
ap_hook_process_connection(h2_c1_hook_process_connection,
mod_reqtimeout, NULL, APR_HOOK_LAST);
/* One last chance to properly say goodbye if we have not done so
* already. */
ap_hook_pre_close_connection(h2_c1_hook_pre_close, NULL, mod_ssl, APR_HOOK_LAST);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.