Loading modules/http2/h2_session.c +1 −1 Original line number Diff line number Diff line Loading @@ -1772,7 +1772,7 @@ static void ev_stream_open(h2_session *session, h2_stream *stream) switch (session->state) { case H2_SESSION_ST_IDLE: if (session->open_streams == 1) { /* enter tiomeout, since we have a stream again */ /* enter timeout, since we have a stream again */ session->idle_until = (session->s->timeout + apr_time_now()); } break; Loading modules/http2/h2_stream.c +44 −39 Original line number Diff line number Diff line Loading @@ -43,18 +43,6 @@ #include "h2_util.h" #define S_XXX (-2) #define S_ERR (-1) #define S_NOP (0) #define S_IDL (H2_SS_IDL + 1) #define S_RS_L (H2_SS_RSVD_L + 1) #define S_RS_R (H2_SS_RSVD_R + 1) #define S_OPEN (H2_SS_OPEN + 1) #define S_CL_L (H2_SS_CLOSED_L + 1) #define S_CL_R (H2_SS_CLOSED_R + 1) #define S_CLS (H2_SS_CLOSED + 1) #define S_CLN (H2_SS_CLEANUP + 1) static const char *h2_ss_str(h2_stream_state_t state) { switch (state) { Loading Loading @@ -84,37 +72,54 @@ const char *h2_stream_state_str(h2_stream *stream) return h2_ss_str(stream->state); } /* Abbreviations for stream transit tables */ #define S_XXX (-2) /* Programming Error */ #define S_ERR (-1) /* Protocol Error */ #define S_NOP (0) /* No Change */ #define S_IDL (H2_SS_IDL + 1) #define S_RS_L (H2_SS_RSVD_L + 1) #define S_RS_R (H2_SS_RSVD_R + 1) #define S_OPEN (H2_SS_OPEN + 1) #define S_CL_L (H2_SS_CLOSED_L + 1) #define S_CL_R (H2_SS_CLOSED_R + 1) #define S_CLS (H2_SS_CLOSED + 1) #define S_CLN (H2_SS_CLEANUP + 1) /* state transisitions when certain frame types are sent */ static int trans_on_send[][H2_SS_MAX] = { /*S_IDLE,S_RS_R, S_RS_L, S_OPEN, S_CL_R, S_CL_L, S_CLS, S_CLN, */ /* DATA, */ { S_ERR, S_ERR, S_ERR, S_NOP, S_NOP, S_ERR, S_NOP, S_NOP, }, /* HEADERS, */ { S_ERR, S_ERR, S_CL_R, S_NOP, S_NOP, S_ERR, S_NOP, S_NOP, }, /* PRIORITY, */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, }, /* RST_STREAM, */ { S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_NOP, S_NOP, }, /* SETTINGS, */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* PUSH_PROMISE, */ { S_RS_L,S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* PING, */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* GOAWAY, */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* WINDOW_UPDATE,*/ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, }, /* CONT */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, }, { S_ERR, S_ERR, S_ERR, S_NOP, S_NOP, S_ERR, S_NOP, S_NOP, },/* DATA */ { S_ERR, S_ERR, S_CL_R, S_NOP, S_NOP, S_ERR, S_NOP, S_NOP, },/* HEADERS */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, },/* PRIORITY */ { S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_NOP, S_NOP, },/* RST_STREAM */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* SETTINGS */ { S_RS_L,S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* PUSH_PROMISE */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* PING */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* GOAWAY */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, },/* WINDOW_UPDATE */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, },/* CONT */ }; /* state transisitions when certain frame types are received */ static int trans_on_recv[][H2_SS_MAX] = { /*S_IDLE,S_RS_R, S_RS_L, S_OPEN, S_CL_R, S_CL_L, S_CLS, S_CLN, */ /* DATA, */ { S_ERR, S_ERR, S_ERR, S_NOP, S_ERR, S_NOP, S_NOP, S_NOP, }, /* HEADERS, */ { S_OPEN,S_CL_L, S_ERR, S_NOP, S_ERR, S_NOP, S_NOP, S_NOP, }, /* PRIORITY, */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, }, /* RST_STREAM, */ { S_ERR, S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_NOP, S_NOP, }, /* SETTINGS, */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* PUSH_PROMISE, */ { S_RS_R,S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* PING, */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* GOAWAY, */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* WINDOW_UPDATE,*/ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, }, /* CONT */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, }, { S_ERR, S_ERR, S_ERR, S_NOP, S_ERR, S_NOP, S_NOP, S_NOP, },/* DATA */ { S_OPEN,S_CL_L, S_ERR, S_NOP, S_ERR, S_NOP, S_NOP, S_NOP, },/* HEADERS */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, },/* PRIORITY */ { S_ERR, S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_NOP, S_NOP, },/* RST_STREAM */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* SETTINGS */ { S_RS_R,S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* PUSH_PROMISE */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* PING */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* GOAWAY */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, },/* WINDOW_UPDATE */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, },/* CONT */ }; /* state transisitions when certain events happen */ static int trans_on_event[][H2_SS_MAX] = { /* H2_SEV_CLOSED_L*/{ S_XXX, S_ERR, S_ERR, S_CL_L, S_CLS, S_XXX, S_XXX, S_XXX, }, /* H2_SEV_CLOSED_R*/{ S_ERR, S_ERR, S_ERR, S_CL_R, S_ERR, S_CLS, S_NOP, S_NOP, }, /* H2_SEV_CANCELLED*/{S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_NOP, S_NOP, }, /* H2_SEV_EOS_SENT*/{ S_NOP, S_XXX, S_XXX, S_XXX, S_XXX, S_CLS, S_CLN, S_XXX, }, /*S_IDLE,S_RS_R, S_RS_L, S_OPEN, S_CL_R, S_CL_L, S_CLS, S_CLN, */ { S_XXX, S_ERR, S_ERR, S_CL_L, S_CLS, S_XXX, S_XXX, S_XXX, },/* EV_CLOSED_L*/ { S_ERR, S_ERR, S_ERR, S_CL_R, S_ERR, S_CLS, S_NOP, S_NOP, },/* EV_CLOSED_R*/ { S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_NOP, S_NOP, },/* EV_CANCELLED*/ { S_NOP, S_XXX, S_XXX, S_XXX, S_XXX, S_CLS, S_CLN, S_XXX, },/* EV_EOS_SENT*/ }; static int on_map(h2_stream_state_t state, int map[H2_SS_MAX]) Loading @@ -137,7 +142,7 @@ static int on_frame(h2_stream_state_t state, int frame_type, ap_assert(frame_type >= 0); ap_assert(state >= 0); if (frame_type >= maxlen) { return state; /* NOP */ return state; /* NOP, ignore unknown frame types */ } return on_map(state, frame_map[frame_type]); } Loading modules/http2/h2_stream.h +19 −3 Original line number Diff line number Diff line Loading @@ -25,10 +25,12 @@ * connection to the client. The h2_session writes to the h2_stream, * adding HEADERS and DATA and finally an EOS. When headers are done, * h2_stream is scheduled for handling, which is expected to produce * a h2_headers. * a response h2_headers at least. * * The h2_headers gives the HEADER frames to sent to the client, followed * by DATA frames read from the h2_stream until EOS is reached. * The h2_headers may be followed by more h2_headers (interim responses) and * by DATA frames read from the h2_stream until EOS is reached. Trailers * are send when a last h2_headers is received. This always closes the stream * output. */ struct h2_mplx; Loading @@ -45,6 +47,9 @@ typedef void h2_stream_state_cb(void *ctx, h2_stream *stream); typedef void h2_stream_event_cb(void *ctx, h2_stream *stream, h2_stream_event_t ev); /** * Callback structure for events and stream state transisitions */ typedef struct h2_stream_monitor { void *ctx; h2_stream_state_cb *on_state_enter; /* called when a state is entered */ Loading Loading @@ -99,6 +104,10 @@ struct h2_stream { * @param id the stream identifier * @param pool the memory pool to use for this stream * @param session the session this stream belongs to * @param monitor an optional monitor to be called for events and * state transisitions * @param initiated_on the id of the stream this one was initiated on (PUSH) * * @return the newly opened stream */ h2_stream *h2_stream_create(int id, apr_pool_t *pool, Loading @@ -111,6 +120,13 @@ h2_stream *h2_stream_create(int id, apr_pool_t *pool, */ void h2_stream_destroy(h2_stream *stream); /** * Prepare the stream so that processing may start. * * This is the time to allocated resources not needed before. * * @param stream the stream to prep */ apr_status_t h2_stream_prep_processing(h2_stream *stream); /* Loading Loading
modules/http2/h2_session.c +1 −1 Original line number Diff line number Diff line Loading @@ -1772,7 +1772,7 @@ static void ev_stream_open(h2_session *session, h2_stream *stream) switch (session->state) { case H2_SESSION_ST_IDLE: if (session->open_streams == 1) { /* enter tiomeout, since we have a stream again */ /* enter timeout, since we have a stream again */ session->idle_until = (session->s->timeout + apr_time_now()); } break; Loading
modules/http2/h2_stream.c +44 −39 Original line number Diff line number Diff line Loading @@ -43,18 +43,6 @@ #include "h2_util.h" #define S_XXX (-2) #define S_ERR (-1) #define S_NOP (0) #define S_IDL (H2_SS_IDL + 1) #define S_RS_L (H2_SS_RSVD_L + 1) #define S_RS_R (H2_SS_RSVD_R + 1) #define S_OPEN (H2_SS_OPEN + 1) #define S_CL_L (H2_SS_CLOSED_L + 1) #define S_CL_R (H2_SS_CLOSED_R + 1) #define S_CLS (H2_SS_CLOSED + 1) #define S_CLN (H2_SS_CLEANUP + 1) static const char *h2_ss_str(h2_stream_state_t state) { switch (state) { Loading Loading @@ -84,37 +72,54 @@ const char *h2_stream_state_str(h2_stream *stream) return h2_ss_str(stream->state); } /* Abbreviations for stream transit tables */ #define S_XXX (-2) /* Programming Error */ #define S_ERR (-1) /* Protocol Error */ #define S_NOP (0) /* No Change */ #define S_IDL (H2_SS_IDL + 1) #define S_RS_L (H2_SS_RSVD_L + 1) #define S_RS_R (H2_SS_RSVD_R + 1) #define S_OPEN (H2_SS_OPEN + 1) #define S_CL_L (H2_SS_CLOSED_L + 1) #define S_CL_R (H2_SS_CLOSED_R + 1) #define S_CLS (H2_SS_CLOSED + 1) #define S_CLN (H2_SS_CLEANUP + 1) /* state transisitions when certain frame types are sent */ static int trans_on_send[][H2_SS_MAX] = { /*S_IDLE,S_RS_R, S_RS_L, S_OPEN, S_CL_R, S_CL_L, S_CLS, S_CLN, */ /* DATA, */ { S_ERR, S_ERR, S_ERR, S_NOP, S_NOP, S_ERR, S_NOP, S_NOP, }, /* HEADERS, */ { S_ERR, S_ERR, S_CL_R, S_NOP, S_NOP, S_ERR, S_NOP, S_NOP, }, /* PRIORITY, */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, }, /* RST_STREAM, */ { S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_NOP, S_NOP, }, /* SETTINGS, */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* PUSH_PROMISE, */ { S_RS_L,S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* PING, */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* GOAWAY, */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* WINDOW_UPDATE,*/ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, }, /* CONT */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, }, { S_ERR, S_ERR, S_ERR, S_NOP, S_NOP, S_ERR, S_NOP, S_NOP, },/* DATA */ { S_ERR, S_ERR, S_CL_R, S_NOP, S_NOP, S_ERR, S_NOP, S_NOP, },/* HEADERS */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, },/* PRIORITY */ { S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_NOP, S_NOP, },/* RST_STREAM */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* SETTINGS */ { S_RS_L,S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* PUSH_PROMISE */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* PING */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* GOAWAY */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, },/* WINDOW_UPDATE */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, },/* CONT */ }; /* state transisitions when certain frame types are received */ static int trans_on_recv[][H2_SS_MAX] = { /*S_IDLE,S_RS_R, S_RS_L, S_OPEN, S_CL_R, S_CL_L, S_CLS, S_CLN, */ /* DATA, */ { S_ERR, S_ERR, S_ERR, S_NOP, S_ERR, S_NOP, S_NOP, S_NOP, }, /* HEADERS, */ { S_OPEN,S_CL_L, S_ERR, S_NOP, S_ERR, S_NOP, S_NOP, S_NOP, }, /* PRIORITY, */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, }, /* RST_STREAM, */ { S_ERR, S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_NOP, S_NOP, }, /* SETTINGS, */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* PUSH_PROMISE, */ { S_RS_R,S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* PING, */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* GOAWAY, */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, }, /* WINDOW_UPDATE,*/ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, }, /* CONT */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, }, { S_ERR, S_ERR, S_ERR, S_NOP, S_ERR, S_NOP, S_NOP, S_NOP, },/* DATA */ { S_OPEN,S_CL_L, S_ERR, S_NOP, S_ERR, S_NOP, S_NOP, S_NOP, },/* HEADERS */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, },/* PRIORITY */ { S_ERR, S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_NOP, S_NOP, },/* RST_STREAM */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* SETTINGS */ { S_RS_R,S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* PUSH_PROMISE */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* PING */ { S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, },/* GOAWAY */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, },/* WINDOW_UPDATE */ { S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, S_NOP, },/* CONT */ }; /* state transisitions when certain events happen */ static int trans_on_event[][H2_SS_MAX] = { /* H2_SEV_CLOSED_L*/{ S_XXX, S_ERR, S_ERR, S_CL_L, S_CLS, S_XXX, S_XXX, S_XXX, }, /* H2_SEV_CLOSED_R*/{ S_ERR, S_ERR, S_ERR, S_CL_R, S_ERR, S_CLS, S_NOP, S_NOP, }, /* H2_SEV_CANCELLED*/{S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_NOP, S_NOP, }, /* H2_SEV_EOS_SENT*/{ S_NOP, S_XXX, S_XXX, S_XXX, S_XXX, S_CLS, S_CLN, S_XXX, }, /*S_IDLE,S_RS_R, S_RS_L, S_OPEN, S_CL_R, S_CL_L, S_CLS, S_CLN, */ { S_XXX, S_ERR, S_ERR, S_CL_L, S_CLS, S_XXX, S_XXX, S_XXX, },/* EV_CLOSED_L*/ { S_ERR, S_ERR, S_ERR, S_CL_R, S_ERR, S_CLS, S_NOP, S_NOP, },/* EV_CLOSED_R*/ { S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_CLS, S_NOP, S_NOP, },/* EV_CANCELLED*/ { S_NOP, S_XXX, S_XXX, S_XXX, S_XXX, S_CLS, S_CLN, S_XXX, },/* EV_EOS_SENT*/ }; static int on_map(h2_stream_state_t state, int map[H2_SS_MAX]) Loading @@ -137,7 +142,7 @@ static int on_frame(h2_stream_state_t state, int frame_type, ap_assert(frame_type >= 0); ap_assert(state >= 0); if (frame_type >= maxlen) { return state; /* NOP */ return state; /* NOP, ignore unknown frame types */ } return on_map(state, frame_map[frame_type]); } Loading
modules/http2/h2_stream.h +19 −3 Original line number Diff line number Diff line Loading @@ -25,10 +25,12 @@ * connection to the client. The h2_session writes to the h2_stream, * adding HEADERS and DATA and finally an EOS. When headers are done, * h2_stream is scheduled for handling, which is expected to produce * a h2_headers. * a response h2_headers at least. * * The h2_headers gives the HEADER frames to sent to the client, followed * by DATA frames read from the h2_stream until EOS is reached. * The h2_headers may be followed by more h2_headers (interim responses) and * by DATA frames read from the h2_stream until EOS is reached. Trailers * are send when a last h2_headers is received. This always closes the stream * output. */ struct h2_mplx; Loading @@ -45,6 +47,9 @@ typedef void h2_stream_state_cb(void *ctx, h2_stream *stream); typedef void h2_stream_event_cb(void *ctx, h2_stream *stream, h2_stream_event_t ev); /** * Callback structure for events and stream state transisitions */ typedef struct h2_stream_monitor { void *ctx; h2_stream_state_cb *on_state_enter; /* called when a state is entered */ Loading Loading @@ -99,6 +104,10 @@ struct h2_stream { * @param id the stream identifier * @param pool the memory pool to use for this stream * @param session the session this stream belongs to * @param monitor an optional monitor to be called for events and * state transisitions * @param initiated_on the id of the stream this one was initiated on (PUSH) * * @return the newly opened stream */ h2_stream *h2_stream_create(int id, apr_pool_t *pool, Loading @@ -111,6 +120,13 @@ h2_stream *h2_stream_create(int id, apr_pool_t *pool, */ void h2_stream_destroy(h2_stream *stream); /** * Prepare the stream so that processing may start. * * This is the time to allocated resources not needed before. * * @param stream the stream to prep */ apr_status_t h2_stream_prep_processing(h2_stream *stream); /* Loading