/* Licensed to the Apache Software Foundation (ASF) under one or more *contributorlicenseagreements.SeetheNOTICEfiledistributedwith *thisworkforadditionalinformationregardingcopyrightownership. *TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0 *(the"License");youmaynotusethisfileexceptincompliancewith *theLicense.YoumayobtainacopyoftheLicenseat * *http://www.apache.org/licenses/LICENSE-2.0 * *Unlessrequiredbyapplicablelaworagreedtoinwriting,software *distributedundertheLicenseisdistributedonan"ASIS"BASIS, *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. *SeetheLicenseforthespecificlanguagegoverningpermissionsand *limitationsundertheLicense.
*/
request_rec *r; /* the request processed in this ctx */
apr_status_t r_status; /* status of request work */ int r_done; /* request was processed, not necessarily successfully */ int r_may_retry; /* request may be retried */ int has_reusable_session; /* http2 session is live and clean */
} h2_proxy_ctx;
status = h2_proxy_session_process(session); if (status != APR_SUCCESS) { /* Encountered an error during session processing */
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, ctx->cfront,
APLOGNO(03375) "eng(%s): end of session %s",
ctx->id, session->id); /* Any open stream of that session needs to *a)bereopenedonthenewsessioniffsafetodoso *b)reportedasdone(failed)otherwise
*/
h2_proxy_session_cleanup(session, session_req_done); goto out;
}
}
/* scheme says, this is for us. */
apr_table_setn(ctx->r->notes, H2_PROXY_REQ_URL_NOTE, url);
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, ctx->r, "H2: serving URL %s", url);
run_connect: if (ctx->cfront->aborted) goto cleanup;
/* Get a proxy_conn_rec from the worker, might be a new one, might *beonestillopenfromanotherrequest,oritmightfailifthe
* worker is stopped or in error. */ if ((status = ap_proxy_acquire_connection(ctx->proxy_func, &ctx->p_conn,
ctx->worker, ctx->server)) != OK) { goto cleanup;
}
locurl = url;
ctx->p_conn->is_ssl = ctx->is_ssl;
/* Step One: Determine the URL to connect to (might be a proxy), *initializethebackendaccordinglyanddeterminetheserver
* port string we can expect in responses. */ if ((status = ap_proxy_determine_connection(ctx->pool, ctx->r, conf, worker,
ctx->p_conn, &uri, &locurl,
proxyname, proxyport,
ctx->server_portstr, sizeof(ctx->server_portstr))) != OK) { goto cleanup;
}
/* Step Two: Make the Connection (or check that an already existing *socketisstillusable).Onsuccess,wehaveasocketconnectedto
* backend->hostname. */ if (ap_proxy_connect_backend(ctx->proxy_func, ctx->p_conn, ctx->worker,
ctx->server)) {
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, ctx->cfront, APLOGNO(03352) "H2: failed to make connection to backend: %s",
ctx->p_conn->hostname); goto cleanup;
}
/* Step Three: Create conn_rec for the socket we have open now. */
status = ap_proxy_connection_create_ex(ctx->proxy_func, ctx->p_conn, ctx->r); if (status != OK) {
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, ctx->cfront, APLOGNO(03353) "setup new connection: is_ssl=%d %s %s %s",
ctx->p_conn->is_ssl, ctx->p_conn->ssl_hostname,
locurl, ctx->p_conn->hostname);
ctx->r_status = status; goto cleanup;
}
if (!ctx->p_conn->data && ctx->is_ssl) { /* New SSL connection: set a note on the connection about what
* protocol we need. */
apr_table_setn(ctx->p_conn->connection->notes, "proxy-request-alpn-protos", "h2");
}
if (ctx->cfront->aborted) goto cleanup;
status = ctx_run(ctx);
if (ctx->r_status != APR_SUCCESS && ctx->r_may_retry && !ctx->cfront->aborted) { /* Not successfully processed, but may retry, tear down old conn and start over */ if (ctx->p_conn) {
ctx->p_conn->close = 1; #if AP_MODULE_MAGIC_AT_LEAST(20140207, 2)
proxy_run_detach_backend(r, ctx->p_conn); #endif
ap_proxy_release_connection(ctx->proxy_func, ctx->p_conn, ctx->server);
ctx->p_conn = NULL;
}
++reconnects; if (reconnects < 2) { goto run_connect;
}
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, ctx->cfront, APLOGNO(10023) "giving up after %d reconnects, request-done=%d",
reconnects, ctx->r_done);
}
cleanup: if (ctx->p_conn) { if (status != APR_SUCCESS || !ctx->has_reusable_session) { /* close socket when errors happened or session is not "clean",
* meaning in a working condition with no open streams */
ctx->p_conn->close = 1;
} #if AP_MODULE_MAGIC_AT_LEAST(20140207, 2)
proxy_run_detach_backend(ctx->r, ctx->p_conn); #endif
ap_proxy_release_connection(ctx->proxy_func, ctx->p_conn, ctx->server);
ctx->p_conn = NULL;
}
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 und die Messung sind noch experimentell.