|
Packit |
90a5c9 |
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
Packit |
90a5c9 |
* contributor license agreements. See the NOTICE file distributed with
|
|
Packit |
90a5c9 |
* this work for additional information regarding copyright ownership.
|
|
Packit |
90a5c9 |
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
Packit |
90a5c9 |
* (the "License"); you may not use this file except in compliance with
|
|
Packit |
90a5c9 |
* the License. You may obtain a copy of the License at
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
90a5c9 |
*
|
|
Packit |
90a5c9 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
90a5c9 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
90a5c9 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
90a5c9 |
* See the License for the specific language governing permissions and
|
|
Packit |
90a5c9 |
* limitations under the License.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include <assert.h>
|
|
Packit |
90a5c9 |
#include <stddef.h>
|
|
Packit |
90a5c9 |
#include <stdlib.h>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include <apr_thread_mutex.h>
|
|
Packit |
90a5c9 |
#include <apr_thread_cond.h>
|
|
Packit |
90a5c9 |
#include <apr_strings.h>
|
|
Packit |
90a5c9 |
#include <apr_time.h>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include <httpd.h>
|
|
Packit |
90a5c9 |
#include <http_core.h>
|
|
Packit |
90a5c9 |
#include <http_log.h>
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "mod_http2.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#include "h2_private.h"
|
|
Packit |
90a5c9 |
#include "h2.h"
|
|
Packit |
90a5c9 |
#include "h2_config.h"
|
|
Packit |
90a5c9 |
#include "h2_conn.h"
|
|
Packit |
90a5c9 |
#include "h2_ctx.h"
|
|
Packit |
90a5c9 |
#include "h2_h2.h"
|
|
Packit |
90a5c9 |
#include "h2_mplx.h"
|
|
Packit |
90a5c9 |
#include "h2_request.h"
|
|
Packit |
90a5c9 |
#include "h2_task.h"
|
|
Packit |
90a5c9 |
#include "h2_util.h"
|
|
Packit |
90a5c9 |
#include "h2_ngn_shed.h"
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
typedef struct h2_ngn_entry h2_ngn_entry;
|
|
Packit |
90a5c9 |
struct h2_ngn_entry {
|
|
Packit |
90a5c9 |
APR_RING_ENTRY(h2_ngn_entry) link;
|
|
Packit |
90a5c9 |
h2_task *task;
|
|
Packit |
90a5c9 |
request_rec *r;
|
|
Packit |
90a5c9 |
};
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define H2_NGN_ENTRY_NEXT(e) APR_RING_NEXT((e), link)
|
|
Packit |
90a5c9 |
#define H2_NGN_ENTRY_PREV(e) APR_RING_PREV((e), link)
|
|
Packit |
90a5c9 |
#define H2_NGN_ENTRY_REMOVE(e) APR_RING_REMOVE((e), link)
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define H2_REQ_ENTRIES_SENTINEL(b) APR_RING_SENTINEL((b), h2_ngn_entry, link)
|
|
Packit |
90a5c9 |
#define H2_REQ_ENTRIES_EMPTY(b) APR_RING_EMPTY((b), h2_ngn_entry, link)
|
|
Packit |
90a5c9 |
#define H2_REQ_ENTRIES_FIRST(b) APR_RING_FIRST(b)
|
|
Packit |
90a5c9 |
#define H2_REQ_ENTRIES_LAST(b) APR_RING_LAST(b)
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define H2_REQ_ENTRIES_INSERT_HEAD(b, e) do { \
|
|
Packit |
90a5c9 |
h2_ngn_entry *ap__b = (e); \
|
|
Packit |
90a5c9 |
APR_RING_INSERT_HEAD((b), ap__b, h2_ngn_entry, link); \
|
|
Packit |
90a5c9 |
} while (0)
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
#define H2_REQ_ENTRIES_INSERT_TAIL(b, e) do { \
|
|
Packit |
90a5c9 |
h2_ngn_entry *ap__b = (e); \
|
|
Packit |
90a5c9 |
APR_RING_INSERT_TAIL((b), ap__b, h2_ngn_entry, link); \
|
|
Packit |
90a5c9 |
} while (0)
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
struct h2_req_engine {
|
|
Packit |
90a5c9 |
const char *id; /* identifier */
|
|
Packit |
90a5c9 |
const char *type; /* name of the engine type */
|
|
Packit |
90a5c9 |
apr_pool_t *pool; /* pool for engine specific allocations */
|
|
Packit |
90a5c9 |
conn_rec *c; /* connection this engine is assigned to */
|
|
Packit |
90a5c9 |
h2_task *task; /* the task this engine is based on, running in */
|
|
Packit |
90a5c9 |
h2_ngn_shed *shed;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
unsigned int shutdown : 1; /* engine is being shut down */
|
|
Packit |
90a5c9 |
unsigned int done : 1; /* engine has finished */
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
APR_RING_HEAD(h2_req_entries, h2_ngn_entry) entries;
|
|
Packit |
90a5c9 |
int capacity; /* maximum concurrent requests */
|
|
Packit |
90a5c9 |
int no_assigned; /* # of assigned requests */
|
|
Packit |
90a5c9 |
int no_live; /* # of live */
|
|
Packit |
90a5c9 |
int no_finished; /* # of finished */
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
h2_output_consumed *out_consumed;
|
|
Packit |
90a5c9 |
void *out_consumed_ctx;
|
|
Packit |
90a5c9 |
};
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
const char *h2_req_engine_get_id(h2_req_engine *engine)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
return engine->id;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
int h2_req_engine_is_shutdown(h2_req_engine *engine)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
return engine->shutdown;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
void h2_req_engine_out_consumed(h2_req_engine *engine, conn_rec *c,
|
|
Packit |
90a5c9 |
apr_off_t bytes)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
if (engine->out_consumed) {
|
|
Packit |
90a5c9 |
engine->out_consumed(engine->out_consumed_ctx, c, bytes);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
h2_ngn_shed *h2_ngn_shed_create(apr_pool_t *pool, conn_rec *c,
|
|
Packit |
90a5c9 |
int default_capacity,
|
|
Packit |
90a5c9 |
apr_size_t req_buffer_size)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
h2_ngn_shed *shed;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
shed = apr_pcalloc(pool, sizeof(*shed));
|
|
Packit |
90a5c9 |
shed->c = c;
|
|
Packit |
90a5c9 |
shed->pool = pool;
|
|
Packit |
90a5c9 |
shed->default_capacity = default_capacity;
|
|
Packit |
90a5c9 |
shed->req_buffer_size = req_buffer_size;
|
|
Packit |
90a5c9 |
shed->ngns = apr_hash_make(pool);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return shed;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
void h2_ngn_shed_set_ctx(h2_ngn_shed *shed, void *user_ctx)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
shed->user_ctx = user_ctx;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
void *h2_ngn_shed_get_ctx(h2_ngn_shed *shed)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
return shed->user_ctx;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
h2_ngn_shed *h2_ngn_shed_get_shed(h2_req_engine *ngn)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
return ngn->shed;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
void h2_ngn_shed_abort(h2_ngn_shed *shed)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, shed->c, APLOGNO(03394)
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): abort", shed->c->id);
|
|
Packit |
90a5c9 |
shed->aborted = 1;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static void ngn_add_task(h2_req_engine *ngn, h2_task *task, request_rec *r)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
h2_ngn_entry *entry = apr_pcalloc(task->pool, sizeof(*entry));
|
|
Packit |
90a5c9 |
APR_RING_ELEM_INIT(entry, link);
|
|
Packit |
90a5c9 |
entry->task = task;
|
|
Packit |
90a5c9 |
entry->r = r;
|
|
Packit |
90a5c9 |
H2_REQ_ENTRIES_INSERT_TAIL(&ngn->entries, entry);
|
|
Packit |
90a5c9 |
ngn->no_assigned++;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_status_t h2_ngn_shed_push_request(h2_ngn_shed *shed, const char *ngn_type,
|
|
Packit |
90a5c9 |
request_rec *r,
|
|
Packit |
90a5c9 |
http2_req_engine_init *einit)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
h2_req_engine *ngn;
|
|
Packit |
90a5c9 |
h2_task *task = h2_ctx_rget_task(r);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ap_assert(task);
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, shed->c,
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): PUSHing request (task=%s)", shed->c->id,
|
|
Packit |
90a5c9 |
task->id);
|
|
Packit |
90a5c9 |
if (task->request->serialize) {
|
|
Packit |
90a5c9 |
/* Max compatibility, deny processing of this */
|
|
Packit |
90a5c9 |
return APR_EOF;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (task->assigned) {
|
|
Packit |
90a5c9 |
--task->assigned->no_assigned;
|
|
Packit |
90a5c9 |
--task->assigned->no_live;
|
|
Packit |
90a5c9 |
task->assigned = NULL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (task->engine) {
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, task->c,
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): push task(%s) hosting engine %s "
|
|
Packit |
90a5c9 |
"already with %d tasks",
|
|
Packit |
90a5c9 |
shed->c->id, task->id, task->engine->id,
|
|
Packit |
90a5c9 |
task->engine->no_assigned);
|
|
Packit |
90a5c9 |
task->assigned = task->engine;
|
|
Packit |
90a5c9 |
ngn_add_task(task->engine, task, r);
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ngn = apr_hash_get(shed->ngns, ngn_type, APR_HASH_KEY_STRING);
|
|
Packit |
90a5c9 |
if (ngn && !ngn->shutdown) {
|
|
Packit |
90a5c9 |
/* this task will be processed in another thread,
|
|
Packit |
90a5c9 |
* freeze any I/O for the time being. */
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, task->c,
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): pushing request %s to %s",
|
|
Packit |
90a5c9 |
shed->c->id, task->id, ngn->id);
|
|
Packit |
90a5c9 |
if (!h2_task_has_thawed(task)) {
|
|
Packit |
90a5c9 |
h2_task_freeze(task);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
ngn_add_task(ngn, task, r);
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
/* no existing engine or being shut down, start a new one */
|
|
Packit |
90a5c9 |
if (einit) {
|
|
Packit |
90a5c9 |
apr_status_t status;
|
|
Packit |
90a5c9 |
apr_pool_t *pool = task->pool;
|
|
Packit |
90a5c9 |
h2_req_engine *newngn;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
newngn = apr_pcalloc(pool, sizeof(*ngn));
|
|
Packit |
90a5c9 |
newngn->pool = pool;
|
|
Packit |
90a5c9 |
newngn->id = apr_psprintf(pool, "ngn-%s", task->id);
|
|
Packit |
90a5c9 |
newngn->type = apr_pstrdup(pool, ngn_type);
|
|
Packit |
90a5c9 |
newngn->c = task->c;
|
|
Packit |
90a5c9 |
newngn->shed = shed;
|
|
Packit |
90a5c9 |
newngn->capacity = shed->default_capacity;
|
|
Packit |
90a5c9 |
newngn->no_assigned = 1;
|
|
Packit |
90a5c9 |
newngn->no_live = 1;
|
|
Packit |
90a5c9 |
APR_RING_INIT(&newngn->entries, h2_ngn_entry, link);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
status = einit(newngn, newngn->id, newngn->type, newngn->pool,
|
|
Packit |
90a5c9 |
shed->req_buffer_size, r,
|
|
Packit |
90a5c9 |
&newngn->out_consumed, &newngn->out_consumed_ctx);
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, task->c, APLOGNO(03395)
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): create engine %s (%s)",
|
|
Packit |
90a5c9 |
shed->c->id, newngn->id, newngn->type);
|
|
Packit |
90a5c9 |
if (status == APR_SUCCESS) {
|
|
Packit |
90a5c9 |
newngn->task = task;
|
|
Packit |
90a5c9 |
task->engine = newngn;
|
|
Packit |
90a5c9 |
task->assigned = newngn;
|
|
Packit |
90a5c9 |
apr_hash_set(shed->ngns, newngn->type, APR_HASH_KEY_STRING, newngn);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return status;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return APR_EOF;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static h2_ngn_entry *pop_detached(h2_req_engine *ngn)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
h2_ngn_entry *entry;
|
|
Packit |
90a5c9 |
for (entry = H2_REQ_ENTRIES_FIRST(&ngn->entries);
|
|
Packit |
90a5c9 |
entry != H2_REQ_ENTRIES_SENTINEL(&ngn->entries);
|
|
Packit |
90a5c9 |
entry = H2_NGN_ENTRY_NEXT(entry)) {
|
|
Packit |
90a5c9 |
if (h2_task_has_thawed(entry->task)
|
|
Packit |
90a5c9 |
|| (entry->task->engine == ngn)) {
|
|
Packit |
90a5c9 |
/* The task hosting this engine can always be pulled by it.
|
|
Packit |
90a5c9 |
* For other task, they need to become detached, e.g. no longer
|
|
Packit |
90a5c9 |
* assigned to another worker. */
|
|
Packit |
90a5c9 |
H2_NGN_ENTRY_REMOVE(entry);
|
|
Packit |
90a5c9 |
return entry;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return NULL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_status_t h2_ngn_shed_pull_request(h2_ngn_shed *shed,
|
|
Packit |
90a5c9 |
h2_req_engine *ngn,
|
|
Packit |
90a5c9 |
int capacity,
|
|
Packit |
90a5c9 |
int want_shutdown,
|
|
Packit |
90a5c9 |
request_rec **pr)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
h2_ngn_entry *entry;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ap_assert(ngn);
|
|
Packit |
90a5c9 |
*pr = NULL;
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_TRACE3, 0, shed->c, APLOGNO(03396)
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): pull task for engine %s, shutdown=%d",
|
|
Packit |
90a5c9 |
shed->c->id, ngn->id, want_shutdown);
|
|
Packit |
90a5c9 |
if (shed->aborted) {
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, shed->c, APLOGNO(03397)
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): abort while pulling requests %s",
|
|
Packit |
90a5c9 |
shed->c->id, ngn->id);
|
|
Packit |
90a5c9 |
ngn->shutdown = 1;
|
|
Packit |
90a5c9 |
return APR_ECONNABORTED;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
ngn->capacity = capacity;
|
|
Packit |
90a5c9 |
if (H2_REQ_ENTRIES_EMPTY(&ngn->entries)) {
|
|
Packit |
90a5c9 |
if (want_shutdown) {
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, shed->c,
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): emtpy queue, shutdown engine %s",
|
|
Packit |
90a5c9 |
shed->c->id, ngn->id);
|
|
Packit |
90a5c9 |
ngn->shutdown = 1;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return ngn->shutdown? APR_EOF : APR_EAGAIN;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if ((entry = pop_detached(ngn))) {
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, entry->task->c, APLOGNO(03398)
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): pulled request %s for engine %s",
|
|
Packit |
90a5c9 |
shed->c->id, entry->task->id, ngn->id);
|
|
Packit |
90a5c9 |
ngn->no_live++;
|
|
Packit |
90a5c9 |
*pr = entry->r;
|
|
Packit |
90a5c9 |
entry->task->assigned = ngn;
|
|
Packit |
90a5c9 |
/* task will now run in ngn's own thread. Modules like lua
|
|
Packit |
90a5c9 |
* seem to require the correct thread set in the conn_rec.
|
|
Packit |
90a5c9 |
* See PR 59542. */
|
|
Packit |
90a5c9 |
if (entry->task->c && ngn->c) {
|
|
Packit |
90a5c9 |
entry->task->c->current_thread = ngn->c->current_thread;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
if (entry->task->engine == ngn) {
|
|
Packit |
90a5c9 |
/* If an engine pushes its own base task, and then pulls
|
|
Packit |
90a5c9 |
* it back to itself again, it needs to be thawed.
|
|
Packit |
90a5c9 |
*/
|
|
Packit |
90a5c9 |
h2_task_thaw(entry->task);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (1) {
|
|
Packit |
90a5c9 |
h2_ngn_entry *entry = H2_REQ_ENTRIES_FIRST(&ngn->entries);
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, shed->c, APLOGNO(03399)
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): pull task, nothing, first task %s",
|
|
Packit |
90a5c9 |
shed->c->id, entry->task->id);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
return APR_EAGAIN;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
static apr_status_t ngn_done_task(h2_ngn_shed *shed, h2_req_engine *ngn,
|
|
Packit |
90a5c9 |
h2_task *task, int waslive, int aborted)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, shed->c, APLOGNO(03400)
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): task %s %s by %s",
|
|
Packit |
90a5c9 |
shed->c->id, task->id, aborted? "aborted":"done", ngn->id);
|
|
Packit |
90a5c9 |
ngn->no_finished++;
|
|
Packit |
90a5c9 |
if (waslive) ngn->no_live--;
|
|
Packit |
90a5c9 |
ngn->no_assigned--;
|
|
Packit |
90a5c9 |
task->assigned = NULL;
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
return APR_SUCCESS;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_status_t h2_ngn_shed_done_task(h2_ngn_shed *shed,
|
|
Packit |
90a5c9 |
struct h2_req_engine *ngn, h2_task *task)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
return ngn_done_task(shed, ngn, task, 1, 0);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
void h2_ngn_shed_done_ngn(h2_ngn_shed *shed, struct h2_req_engine *ngn)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
if (ngn->done) {
|
|
Packit |
90a5c9 |
return;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
if (!shed->aborted && !H2_REQ_ENTRIES_EMPTY(&ngn->entries)) {
|
|
Packit |
90a5c9 |
h2_ngn_entry *entry;
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, shed->c,
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): exit engine %s (%s), "
|
|
Packit |
90a5c9 |
"has still requests queued, shutdown=%d,"
|
|
Packit |
90a5c9 |
"assigned=%ld, live=%ld, finished=%ld",
|
|
Packit |
90a5c9 |
shed->c->id, ngn->id, ngn->type,
|
|
Packit |
90a5c9 |
ngn->shutdown,
|
|
Packit |
90a5c9 |
(long)ngn->no_assigned, (long)ngn->no_live,
|
|
Packit |
90a5c9 |
(long)ngn->no_finished);
|
|
Packit |
90a5c9 |
for (entry = H2_REQ_ENTRIES_FIRST(&ngn->entries);
|
|
Packit |
90a5c9 |
entry != H2_REQ_ENTRIES_SENTINEL(&ngn->entries);
|
|
Packit |
90a5c9 |
entry = H2_NGN_ENTRY_NEXT(entry)) {
|
|
Packit |
90a5c9 |
h2_task *task = entry->task;
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, shed->c,
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): engine %s has queued task %s, "
|
|
Packit |
90a5c9 |
"frozen=%d, aborting",
|
|
Packit |
90a5c9 |
shed->c->id, ngn->id, task->id, task->frozen);
|
|
Packit |
90a5c9 |
ngn_done_task(shed, ngn, task, 0, 1);
|
|
Packit |
90a5c9 |
task->engine = task->assigned = NULL;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
if (!shed->aborted && (ngn->no_assigned > 1 || ngn->no_live > 1)) {
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, shed->c,
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): exit engine %s (%s), "
|
|
Packit |
90a5c9 |
"assigned=%ld, live=%ld, finished=%ld",
|
|
Packit |
90a5c9 |
shed->c->id, ngn->id, ngn->type,
|
|
Packit |
90a5c9 |
(long)ngn->no_assigned, (long)ngn->no_live,
|
|
Packit |
90a5c9 |
(long)ngn->no_finished);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
else {
|
|
Packit |
90a5c9 |
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, shed->c,
|
|
Packit |
90a5c9 |
"h2_ngn_shed(%ld): exit engine %s",
|
|
Packit |
90a5c9 |
shed->c->id, ngn->id);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
apr_hash_set(shed->ngns, ngn->type, APR_HASH_KEY_STRING, NULL);
|
|
Packit |
90a5c9 |
ngn->done = 1;
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|
|
Packit |
90a5c9 |
void h2_ngn_shed_destroy(h2_ngn_shed *shed)
|
|
Packit |
90a5c9 |
{
|
|
Packit |
90a5c9 |
ap_assert(apr_hash_count(shed->ngns) == 0);
|
|
Packit |
90a5c9 |
}
|
|
Packit |
90a5c9 |
|