Apache HTTPD
Classes | Macros | Typedefs | Functions
h2_mplx.h File Reference
#include <apr_queue.h>
#include "h2_workers.h"

Go to the source code of this file.

Classes

struct  h2_c2_transit
 
struct  h2_mplx
 

Macros

#define H2_MPLX_MSG(m, msg)    "h2_mplx(%d-%lu): "msg, m->child_num, (unsigned long)m->id
 

Typedefs

typedef struct h2_c2_transit h2_c2_transit
 
typedef struct h2_mplx h2_mplx
 
typedef void stream_ev_callback(void *ctx, struct h2_stream *stream)
 
typedef int h2_mplx_stream_cb(struct h2_stream *s, void *userdata)
 

Functions

apr_status_t h2_mplx_c1_child_init (apr_pool_t *pool, server_rec *s)
 
h2_mplxh2_mplx_c1_create (int child_id, apr_uint32_t id, struct h2_stream *stream0, server_rec *s, apr_pool_t *master, struct h2_workers *workers)
 
void h2_mplx_c1_destroy (h2_mplx *m)
 
int h2_mplx_c1_shutdown (h2_mplx *m)
 
apr_status_t h2_mplx_c1_stream_cleanup (h2_mplx *m, struct h2_stream *stream, unsigned int *pstream_count)
 
int h2_mplx_c1_stream_is_running (h2_mplx *m, struct h2_stream *stream)
 
void h2_mplx_c1_process (h2_mplx *m, struct h2_iqueue *read_to_process, h2_stream_get_fn *get_stream, h2_stream_pri_cmp_fn *cmp, struct h2_session *session, unsigned int *pstream_count)
 
apr_status_t h2_mplx_c1_reprioritize (h2_mplx *m, h2_stream_pri_cmp_fn *cmp, struct h2_session *session)
 
apr_status_t h2_mplx_c1_poll (h2_mplx *m, apr_interval_time_t timeout, stream_ev_callback *on_stream_input, stream_ev_callback *on_stream_output, void *on_ctx)
 
void h2_mplx_c2_input_read (h2_mplx *m, conn_rec *c2)
 
void h2_mplx_c2_output_written (h2_mplx *m, conn_rec *c2)
 
apr_status_t h2_mplx_c1_streams_do (h2_mplx *m, h2_mplx_stream_cb *cb, void *ctx)
 
int h2_mplx_c1_all_streams_want_send_data (h2_mplx *m)
 
apr_status_t h2_mplx_c1_client_rst (h2_mplx *m, int stream_id, struct h2_stream *stream)
 
const struct h2_streamh2_mplx_c2_stream_get (h2_mplx *m, int stream_id)
 
apr_status_t h2_mplx_worker_pop_c2 (h2_mplx *m, conn_rec **out_c2)
 
void h2_mplx_c1_going_keepalive (h2_mplx *m)
 

Macro Definition Documentation

◆ H2_MPLX_MSG

#define H2_MPLX_MSG (   m,
  msg 
)     "h2_mplx(%d-%lu): "msg, m->child_num, (unsigned long)m->id

Definition at line 227 of file h2_mplx.h.

Typedef Documentation

◆ h2_c2_transit

Definition at line 49 of file h2_mplx.h.

◆ h2_mplx

Definition at line 56 of file h2_mplx.h.

◆ h2_mplx_stream_cb

typedef int h2_mplx_stream_cb(struct h2_stream *s, void *userdata)

Definition at line 184 of file h2_mplx.h.

◆ stream_ev_callback

typedef void stream_ev_callback(void *ctx, struct h2_stream *stream)

Definition at line 170 of file h2_mplx.h.

Function Documentation

◆ h2_mplx_c1_all_streams_want_send_data()

int h2_mplx_c1_all_streams_want_send_data ( h2_mplx m)

Return != 0 iff all open streams want to send data

Definition at line 411 of file h2_mplx.c.

◆ h2_mplx_c1_child_init()

apr_status_t h2_mplx_c1_child_init ( apr_pool_t pool,
server_rec s 
)

Definition at line 83 of file h2_mplx.c.

◆ h2_mplx_c1_client_rst()

apr_status_t h2_mplx_c1_client_rst ( h2_mplx m,
int  stream_id,
struct h2_stream stream 
)

A stream has been RST_STREAM by the client. Abort any processing going on and remove from processing queue.

Definition at line 1122 of file h2_mplx.c.

◆ h2_mplx_c1_create()

h2_mplx * h2_mplx_c1_create ( int  child_num,
apr_uint32_t  id,
h2_stream stream0,
server_rec s,
apr_pool_t parent,
h2_workers workers 
)

Create the multiplexer for the given HTTP2 session. Implicitly has reference count 1.

A h2_mplx needs to be thread-safe and if will be called by the h2_session thread and the h2_worker threads. Therefore:

  • calls are protected by a mutex lock, m->lock
  • the pool needs its own allocator, since apr_allocator_t are not re-entrant. The separate allocator works without a separate lock since we already protect h2_mplx itself. Since HTTP/2 connections can be expected to live longer than their HTTP/1 cousins, the separate allocator seems to work better than protecting a shared h2_session one with an own lock.

Definition at line 258 of file h2_mplx.c.

◆ h2_mplx_c1_destroy()

void h2_mplx_c1_destroy ( h2_mplx m)

Destroy the mplx, shutting down all ongoing processing.

Parameters
mthe mplx destroyed
waitcondition var to wait on for ref counter == 0

Definition at line 471 of file h2_mplx.c.

◆ h2_mplx_c1_going_keepalive()

void h2_mplx_c1_going_keepalive ( h2_mplx m)

Session processing is entering KEEPALIVE, e.g. giving control to the MPM for monitoring incoming socket events only. Last chance for maintenance work before losing control.

Definition at line 605 of file h2_mplx.c.

◆ h2_mplx_c1_poll()

apr_status_t h2_mplx_c1_poll ( h2_mplx m,
apr_interval_time_t  timeout,
stream_ev_callback on_stream_input,
stream_ev_callback on_stream_output,
void *  on_ctx 
)

Poll the primary connection for input and the active streams for output. Invoke the callback for any stream where an event happened.

Definition at line 614 of file h2_mplx.c.

◆ h2_mplx_c1_process()

void h2_mplx_c1_process ( h2_mplx m,
struct h2_iqueue read_to_process,
h2_stream_get_fn get_stream,
h2_stream_pri_cmp_fn cmp,
struct h2_session session,
unsigned int pstream_count 
)

Process a stream request.

Parameters
mthe multiplexer
read_to_process
input_pending
cmpthe stream priority compare function
pstream_counton return the number of streams active in mplx

Definition at line 711 of file h2_mplx.c.

◆ h2_mplx_c1_reprioritize()

apr_status_t h2_mplx_c1_reprioritize ( h2_mplx m,
h2_stream_pri_cmp_fn cmp,
struct h2_session session 
)

Stream priorities have changed, reschedule pending requests.

Parameters
mthe multiplexer
cmpthe stream priority compare function
ctxcontext data for the compare function

Definition at line 643 of file h2_mplx.c.

◆ h2_mplx_c1_shutdown()

int h2_mplx_c1_shutdown ( h2_mplx m)

Shut down the multiplexer gracefully. Will no longer schedule new streams but let the ongoing ones finish normally.

Returns
the highest stream id being/been processed

Definition at line 358 of file h2_mplx.c.

◆ h2_mplx_c1_stream_cleanup()

apr_status_t h2_mplx_c1_stream_cleanup ( h2_mplx m,
struct h2_stream stream,
unsigned int pstream_count 
)

Notifies mplx that a stream has been completely handled on the main connection and is ready for cleanup.

Parameters
mthe mplx itself
streamthe stream ready for cleanup
pstream_countreturn the number of streams active

Definition at line 549 of file h2_mplx.c.

◆ h2_mplx_c1_stream_is_running()

int h2_mplx_c1_stream_is_running ( h2_mplx m,
struct h2_stream stream 
)

Definition at line 118 of file h2_mplx.c.

◆ h2_mplx_c1_streams_do()

apr_status_t h2_mplx_c1_streams_do ( h2_mplx m,
h2_mplx_stream_cb cb,
void *  ctx 
)

Iterate over all streams known to mplx from the primary connection.

Parameters
mthe mplx
cbthe callback to invoke on each stream
ctxuserdata passed to the callback

Definition at line 383 of file h2_mplx.c.

◆ h2_mplx_c2_input_read()

void h2_mplx_c2_input_read ( h2_mplx m,
conn_rec c2 
)

◆ h2_mplx_c2_output_written()

void h2_mplx_c2_output_written ( h2_mplx m,
conn_rec c2 
)

◆ h2_mplx_c2_stream_get()

const struct h2_stream * h2_mplx_c2_stream_get ( h2_mplx m,
int  stream_id 
)

Get readonly access to a stream for a secondary connection.

Definition at line 562 of file h2_mplx.c.

◆ h2_mplx_worker_pop_c2()

apr_status_t h2_mplx_worker_pop_c2 ( h2_mplx m,
conn_rec **  out_c2 
)

A h2 worker asks for a secondary connection to process.

Parameters
out_c2non-NULL, a pointer where to reveive the next secondary connection to process.