Apache HTTPD
Classes | Typedefs | Enumerations | Functions
h2_workers.c File Reference
#include <assert.h>
#include <apr_ring.h>
#include <apr_thread_mutex.h>
#include <apr_thread_cond.h>
#include <mpm_common.h>
#include <httpd.h>
#include <http_connection.h>
#include <http_core.h>
#include <http_log.h>
#include <http_protocol.h>
#include "h2.h"
#include "h2_private.h"
#include "h2_mplx.h"
#include "h2_c2.h"
#include "h2_workers.h"
#include "h2_util.h"

Go to the source code of this file.

Classes

struct  ap_conn_producer_t
 
struct  h2_slot
 
struct  h2_workers
 
struct  h2_workers::h2_slots_free
 
struct  h2_workers::h2_slots_idle
 
struct  h2_workers::h2_slots_busy
 
struct  h2_workers::h2_slots_zombie
 
struct  h2_workers::ap_conn_producer_active
 
struct  h2_workers::ap_conn_producer_idle
 

Typedefs

typedef struct h2_slot h2_slot
 

Enumerations

enum  prod_state_t { PROD_IDLE , PROD_ACTIVE , PROD_JOINED }
 
enum  h2_slot_state_t { H2_SLOT_FREE , H2_SLOT_RUN , H2_SLOT_ZOMBIE }
 

Functions

static void *APR_THREAD_FUNC slot_run (apr_thread_t *thread, void *wctx)
 
static apr_status_t activate_slot (h2_workers *workers)
 
static void join_zombies (h2_workers *workers)
 
static void wake_idle_worker (h2_workers *workers, ap_conn_producer_t *prod)
 
static conn_recget_next (h2_slot *slot)
 
static void wake_all_idles (h2_workers *workers)
 
static apr_status_t workers_pool_cleanup (void *data)
 
h2_workersh2_workers_create (server_rec *s, apr_pool_t *pchild, int max_slots, int min_active, apr_time_t idle_limit)
 
apr_uint32_t h2_workers_get_max_workers (h2_workers *workers)
 
void h2_workers_shutdown (h2_workers *workers, int graceful)
 
ap_conn_producer_th2_workers_register (h2_workers *workers, apr_pool_t *producer_pool, const char *name, ap_conn_producer_next *fn_next, ap_conn_producer_done *fn_done, ap_conn_producer_shutdown *fn_shutdown, void *baton)
 
apr_status_t h2_workers_join (h2_workers *workers, ap_conn_producer_t *prod)
 
apr_status_t h2_workers_activate (h2_workers *workers, ap_conn_producer_t *prod)
 

Typedef Documentation

◆ h2_slot

Definition at line 60 of file h2_workers.c.

Enumeration Type Documentation

◆ h2_slot_state_t

Enumerator
H2_SLOT_FREE 
H2_SLOT_RUN 
H2_SLOT_ZOMBIE 

Definition at line 54 of file h2_workers.c.

◆ prod_state_t

Enumerator
PROD_IDLE 
PROD_ACTIVE 
PROD_JOINED 

Definition at line 36 of file h2_workers.c.

Function Documentation

◆ activate_slot()

static apr_status_t activate_slot ( h2_workers workers)
static

Definition at line 108 of file h2_workers.c.

◆ get_next()

static conn_rec * get_next ( h2_slot slot)
static

Get the next connection to work on.

Definition at line 199 of file h2_workers.c.

◆ h2_workers_activate()

apr_status_t h2_workers_activate ( h2_workers workers,
ap_conn_producer_t producer 
)

Activate a producer. A worker will query the producer for a connection to process, once a worker is available. This may be called, irregardless of the producers active/inactive.

Definition at line 611 of file h2_workers.c.

◆ h2_workers_create()

h2_workers * h2_workers_create ( server_rec s,
apr_pool_t pool,
int  max_slots,
int  min_active,
apr_time_t  idle_limit 
)

Create a worker set with a maximum number of 'slots', e.g. worker threads to run. Always keep min_active workers running. Shutdown any additional workers after idle_secs seconds of doing nothing.

@oaram s the base server

Parameters
poolfor allocations
min_activeminimum number of workers to run
max_slotsmaximum number of worker slots
idle_limitupper duration of idle after a non-minimal slots shuts down

Definition at line 422 of file h2_workers.c.

◆ h2_workers_get_max_workers()

apr_uint32_t h2_workers_get_max_workers ( h2_workers workers)

Get the maximum number of workers.

Definition at line 538 of file h2_workers.c.

◆ h2_workers_join()

apr_status_t h2_workers_join ( h2_workers workers,
ap_conn_producer_t producer 
)

Stop retrieving more connection from the producer and wait for all ongoing for from that producer to be done.

Definition at line 589 of file h2_workers.c.

◆ h2_workers_register()

ap_conn_producer_t * h2_workers_register ( h2_workers workers,
apr_pool_t producer_pool,
const char name,
ap_conn_producer_next fn_next,
ap_conn_producer_done fn_done,
ap_conn_producer_shutdown fn_shutdown,
void *  baton 
)

Register a new producer with the given baton and callback functions. Will allocate internal structures from the given pool (but make no use of the pool after registration). Producers are inactive on registration. See h2_workers_activate().

Parameters
producer_poolto allocate the producer from
namedescriptive name of the producer, must not be unique
fn_nextcallback for retrieving connections to process
fn_donecallback for processed connections
batonprovided value passed on in callbacks
Returns
the producer instance created

Definition at line 563 of file h2_workers.c.

◆ h2_workers_shutdown()

void h2_workers_shutdown ( h2_workers workers,
int  graceful 
)

Shut down processing.

Definition at line 543 of file h2_workers.c.

◆ join_zombies()

static void join_zombies ( h2_workers workers)
static

Definition at line 151 of file h2_workers.c.

◆ slot_run()

static void *APR_THREAD_FUNC slot_run ( apr_thread_t thread,
void *  wctx 
)
static

Definition at line 229 of file h2_workers.c.

◆ wake_all_idles()

static void wake_all_idles ( h2_workers workers)
static

Definition at line 356 of file h2_workers.c.

◆ wake_idle_worker()

static void wake_idle_worker ( h2_workers workers,
ap_conn_producer_t prod 
)
static

Definition at line 176 of file h2_workers.c.

◆ workers_pool_cleanup()

static apr_status_t workers_pool_cleanup ( void *  data)
static

Definition at line 367 of file h2_workers.c.