Refactor storage of settings
Now local and remote settings values are stored in dedicated structure nghttp2_settings_storage.
This commit is contained in:
parent
4596f73ee0
commit
2878e1e258
|
@ -519,10 +519,6 @@ typedef enum {
|
||||||
* SETTINGS_INITIAL_WINDOW_SIZE
|
* SETTINGS_INITIAL_WINDOW_SIZE
|
||||||
*/
|
*/
|
||||||
NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE = 4,
|
NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE = 4,
|
||||||
/**
|
|
||||||
* Maximum ID of :type:`nghttp2_settings_id`.
|
|
||||||
*/
|
|
||||||
NGHTTP2_SETTINGS_MAX = 4
|
|
||||||
} nghttp2_settings_id;
|
} nghttp2_settings_id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2030,6 +2026,8 @@ int nghttp2_session_terminate_session(nghttp2_session *session,
|
||||||
* @function
|
* @function
|
||||||
*
|
*
|
||||||
* Returns the value of SETTINGS |id| notified by a remote endpoint.
|
* Returns the value of SETTINGS |id| notified by a remote endpoint.
|
||||||
|
* The |id| must be one of values defined in
|
||||||
|
* :enum:`nghttp2_settings_id`.
|
||||||
*/
|
*/
|
||||||
uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session,
|
uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session,
|
||||||
nghttp2_settings_id id);
|
nghttp2_settings_id id);
|
||||||
|
|
|
@ -37,24 +37,24 @@
|
||||||
/*
|
/*
|
||||||
* Returns non-zero if the number of outgoing opened streams is larger
|
* Returns non-zero if the number of outgoing opened streams is larger
|
||||||
* than or equal to
|
* than or equal to
|
||||||
* remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS].
|
* remote_settings.max_concurrent_streams.
|
||||||
*/
|
*/
|
||||||
static int session_is_outgoing_concurrent_streams_max
|
static int session_is_outgoing_concurrent_streams_max
|
||||||
(nghttp2_session *session)
|
(nghttp2_session *session)
|
||||||
{
|
{
|
||||||
return session->remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]
|
return session->remote_settings.max_concurrent_streams
|
||||||
<= session->num_outgoing_streams;
|
<= session->num_outgoing_streams;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns non-zero if the number of incoming opened streams is larger
|
* Returns non-zero if the number of incoming opened streams is larger
|
||||||
* than or equal to
|
* than or equal to
|
||||||
* local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS].
|
* local_settings.max_concurrent_streams.
|
||||||
*/
|
*/
|
||||||
static int session_is_incoming_concurrent_streams_max
|
static int session_is_incoming_concurrent_streams_max
|
||||||
(nghttp2_session *session)
|
(nghttp2_session *session)
|
||||||
{
|
{
|
||||||
return session->local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]
|
return session->local_settings.max_concurrent_streams
|
||||||
<= session->num_incoming_streams;
|
<= session->num_incoming_streams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,15 +255,12 @@ static void session_inbound_frame_reset(nghttp2_session *session)
|
||||||
iframe->padlen = 0;
|
iframe->padlen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_settings(uint32_t *settings)
|
static void init_settings(nghttp2_settings_storage *settings)
|
||||||
{
|
{
|
||||||
settings[NGHTTP2_SETTINGS_HEADER_TABLE_SIZE] =
|
settings->header_table_size = NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE;
|
||||||
NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE;
|
settings->enable_push = 1;
|
||||||
settings[NGHTTP2_SETTINGS_ENABLE_PUSH] = 1;
|
settings->max_concurrent_streams = NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS;
|
||||||
settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] =
|
settings->initial_window_size = NGHTTP2_INITIAL_WINDOW_SIZE;
|
||||||
NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS;
|
|
||||||
settings[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] =
|
|
||||||
NGHTTP2_INITIAL_WINDOW_SIZE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void active_outbound_item_reset(nghttp2_active_outbound_item *aob)
|
static void active_outbound_item_reset(nghttp2_active_outbound_item *aob)
|
||||||
|
@ -348,8 +345,8 @@ static int session_new(nghttp2_session **session_ptr,
|
||||||
|
|
||||||
active_outbound_item_reset(&(*session_ptr)->aob);
|
active_outbound_item_reset(&(*session_ptr)->aob);
|
||||||
|
|
||||||
init_settings((*session_ptr)->remote_settings);
|
init_settings(&(*session_ptr)->remote_settings);
|
||||||
init_settings((*session_ptr)->local_settings);
|
init_settings(&(*session_ptr)->local_settings);
|
||||||
|
|
||||||
|
|
||||||
if(option) {
|
if(option) {
|
||||||
|
@ -371,8 +368,7 @@ static int session_new(nghttp2_session **session_ptr,
|
||||||
|
|
||||||
if(option->opt_set_mask & NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS) {
|
if(option->opt_set_mask & NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS) {
|
||||||
|
|
||||||
(*session_ptr)->
|
(*session_ptr)->remote_settings.max_concurrent_streams =
|
||||||
remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] =
|
|
||||||
option->peer_max_concurrent_streams;
|
option->peer_max_concurrent_streams;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -730,10 +726,8 @@ nghttp2_stream* nghttp2_session_open_stream(nghttp2_session *session,
|
||||||
|
|
||||||
nghttp2_stream_init(stream, stream_id, flags, initial_state,
|
nghttp2_stream_init(stream, stream_id, flags, initial_state,
|
||||||
pri_spec->weight, &session->roots,
|
pri_spec->weight, &session->roots,
|
||||||
session->remote_settings
|
session->remote_settings.initial_window_size,
|
||||||
[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE],
|
session->local_settings.initial_window_size,
|
||||||
session->local_settings
|
|
||||||
[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE],
|
|
||||||
stream_user_data);
|
stream_user_data);
|
||||||
|
|
||||||
rv = nghttp2_map_insert(&session->streams, &stream->map_entry);
|
rv = nghttp2_map_insert(&session->streams, &stream->map_entry);
|
||||||
|
@ -920,9 +914,7 @@ void nghttp2_session_adjust_closed_stream(nghttp2_session *session,
|
||||||
{
|
{
|
||||||
size_t num_stream_max;
|
size_t num_stream_max;
|
||||||
|
|
||||||
num_stream_max =
|
num_stream_max = nghttp2_min(session->local_settings.max_concurrent_streams,
|
||||||
nghttp2_min
|
|
||||||
(session->local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS],
|
|
||||||
session->pending_local_max_concurrent_stream);
|
session->pending_local_max_concurrent_stream);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: adjusting kept closed streams "
|
DEBUGF(fprintf(stderr, "stream: adjusting kept closed streams "
|
||||||
|
@ -1206,7 +1198,7 @@ static int session_predicate_push_promise_send
|
||||||
if(rv != 0) {
|
if(rv != 0) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
if(session->remote_settings[NGHTTP2_SETTINGS_ENABLE_PUSH] == 0) {
|
if(session->remote_settings.enable_push == 0) {
|
||||||
return NGHTTP2_ERR_PUSH_DISABLED;
|
return NGHTTP2_ERR_PUSH_DISABLED;
|
||||||
}
|
}
|
||||||
if(stream->state == NGHTTP2_STREAM_CLOSING) {
|
if(stream->state == NGHTTP2_STREAM_CLOSING) {
|
||||||
|
@ -3212,10 +3204,11 @@ static int session_update_remote_initial_window_size
|
||||||
int32_t new_initial_window_size)
|
int32_t new_initial_window_size)
|
||||||
{
|
{
|
||||||
nghttp2_update_window_size_arg arg;
|
nghttp2_update_window_size_arg arg;
|
||||||
|
|
||||||
arg.session = session;
|
arg.session = session;
|
||||||
arg.new_window_size = new_initial_window_size;
|
arg.new_window_size = new_initial_window_size;
|
||||||
arg.old_window_size =
|
arg.old_window_size = session->remote_settings.initial_window_size;
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE];
|
|
||||||
return nghttp2_map_each(&session->streams,
|
return nghttp2_map_each(&session->streams,
|
||||||
update_remote_initial_window_size_func,
|
update_remote_initial_window_size_func,
|
||||||
&arg);
|
&arg);
|
||||||
|
@ -3322,18 +3315,32 @@ int nghttp2_session_update_local_settings(nghttp2_session *session,
|
||||||
rv = session_update_local_initial_window_size
|
rv = session_update_local_initial_window_size
|
||||||
(session,
|
(session,
|
||||||
new_initial_window_size,
|
new_initial_window_size,
|
||||||
session->local_settings[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]);
|
session->local_settings.initial_window_size);
|
||||||
if(rv != 0) {
|
if(rv != 0) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < niv; ++i) {
|
for(i = 0; i < niv; ++i) {
|
||||||
if(iv[i].settings_id > 0 && iv[i].settings_id <= NGHTTP2_SETTINGS_MAX) {
|
switch(iv[i].settings_id) {
|
||||||
session->local_settings[iv[i].settings_id] = iv[i].value;
|
case NGHTTP2_SETTINGS_HEADER_TABLE_SIZE:
|
||||||
|
session->local_settings.header_table_size = iv[i].value;
|
||||||
|
break;
|
||||||
|
case NGHTTP2_SETTINGS_ENABLE_PUSH:
|
||||||
|
session->local_settings.enable_push = iv[i].value;
|
||||||
|
break;
|
||||||
|
case NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS:
|
||||||
|
session->local_settings.max_concurrent_streams = iv[i].value;
|
||||||
|
break;
|
||||||
|
case NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:
|
||||||
|
session->local_settings.initial_window_size = iv[i].value;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session->pending_local_max_concurrent_stream =
|
session->pending_local_max_concurrent_stream =
|
||||||
NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS;
|
NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3343,7 +3350,11 @@ int nghttp2_session_on_settings_received(nghttp2_session *session,
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
int i;
|
int i;
|
||||||
int check[NGHTTP2_SETTINGS_MAX+1];
|
int header_table_size_seen = 0;
|
||||||
|
int enable_push_seen = 0;
|
||||||
|
int max_concurrent_streams_seen = 0;
|
||||||
|
int initial_window_size_seen = 0;
|
||||||
|
|
||||||
if(frame->hd.stream_id != 0) {
|
if(frame->hd.stream_id != 0) {
|
||||||
return session_handle_invalid_connection(session, frame,
|
return session_handle_invalid_connection(session, frame,
|
||||||
NGHTTP2_PROTOCOL_ERROR);
|
NGHTTP2_PROTOCOL_ERROR);
|
||||||
|
@ -3374,25 +3385,27 @@ int nghttp2_session_on_settings_received(nghttp2_session *session,
|
||||||
}
|
}
|
||||||
return session_call_on_frame_received(session, frame);
|
return session_call_on_frame_received(session, frame);
|
||||||
}
|
}
|
||||||
/* Check ID/value pairs and persist them if necessary. */
|
|
||||||
memset(check, 0, sizeof(check));
|
|
||||||
for(i = (int)frame->settings.niv - 1; i >= 0; --i) {
|
for(i = (int)frame->settings.niv - 1; i >= 0; --i) {
|
||||||
nghttp2_settings_entry *entry = &frame->settings.iv[i];
|
nghttp2_settings_entry *entry = &frame->settings.iv[i];
|
||||||
|
|
||||||
/* The spec says the settings values are processed in the order
|
/* The spec says the settings values are processed in the order
|
||||||
they appear in the payload. In other words, if the multiple
|
they appear in the payload. In other words, if the multiple
|
||||||
values for the same ID were found, use the last one and ignore
|
values for the same ID were found, use the last one and ignore
|
||||||
the rest. */
|
the rest. */
|
||||||
if(entry->settings_id > NGHTTP2_SETTINGS_MAX || entry->settings_id <= 0 ||
|
|
||||||
check[entry->settings_id] == 1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
check[entry->settings_id] = 1;
|
|
||||||
switch(entry->settings_id) {
|
switch(entry->settings_id) {
|
||||||
case NGHTTP2_SETTINGS_HEADER_TABLE_SIZE:
|
case NGHTTP2_SETTINGS_HEADER_TABLE_SIZE:
|
||||||
|
if(header_table_size_seen) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
header_table_size_seen = 1;
|
||||||
|
|
||||||
if(entry->value > NGHTTP2_MAX_HEADER_TABLE_SIZE) {
|
if(entry->value > NGHTTP2_MAX_HEADER_TABLE_SIZE) {
|
||||||
return session_handle_invalid_connection
|
return session_handle_invalid_connection
|
||||||
(session, frame, NGHTTP2_COMPRESSION_ERROR);
|
(session, frame, NGHTTP2_COMPRESSION_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = nghttp2_hd_deflate_change_table_size(&session->hd_deflater,
|
rv = nghttp2_hd_deflate_change_table_size(&session->hd_deflater,
|
||||||
entry->value);
|
entry->value);
|
||||||
if(rv != 0) {
|
if(rv != 0) {
|
||||||
|
@ -3403,46 +3416,84 @@ int nghttp2_session_on_settings_received(nghttp2_session *session,
|
||||||
(session, frame, NGHTTP2_COMPRESSION_ERROR);
|
(session, frame, NGHTTP2_COMPRESSION_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session->remote_settings.header_table_size = entry->value;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_SETTINGS_ENABLE_PUSH:
|
case NGHTTP2_SETTINGS_ENABLE_PUSH:
|
||||||
|
if(enable_push_seen) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
enable_push_seen = 1;
|
||||||
|
|
||||||
if(entry->value != 0 && entry->value != 1) {
|
if(entry->value != 0 && entry->value != 1) {
|
||||||
return session_handle_invalid_connection
|
return session_handle_invalid_connection
|
||||||
(session, frame, NGHTTP2_PROTOCOL_ERROR);
|
(session, frame, NGHTTP2_PROTOCOL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!session->server && entry->value != 0) {
|
if(!session->server && entry->value != 0) {
|
||||||
return session_handle_invalid_connection
|
return session_handle_invalid_connection
|
||||||
(session, frame, NGHTTP2_PROTOCOL_ERROR);
|
(session, frame, NGHTTP2_PROTOCOL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session->remote_settings.enable_push = entry->value;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS:
|
||||||
|
if(max_concurrent_streams_seen) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
max_concurrent_streams_seen = 1;
|
||||||
|
|
||||||
|
session->remote_settings.max_concurrent_streams = entry->value;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:
|
case NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:
|
||||||
|
if(initial_window_size_seen) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
initial_window_size_seen = 1;
|
||||||
|
|
||||||
/* Update the initial window size of the all active streams */
|
/* Update the initial window size of the all active streams */
|
||||||
/* Check that initial_window_size < (1u << 31) */
|
/* Check that initial_window_size < (1u << 31) */
|
||||||
if(entry->value > NGHTTP2_MAX_WINDOW_SIZE) {
|
if(entry->value > NGHTTP2_MAX_WINDOW_SIZE) {
|
||||||
return session_handle_invalid_connection
|
return session_handle_invalid_connection
|
||||||
(session, frame, NGHTTP2_FLOW_CONTROL_ERROR);
|
(session, frame, NGHTTP2_FLOW_CONTROL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = session_update_remote_initial_window_size(session, entry->value);
|
rv = session_update_remote_initial_window_size(session, entry->value);
|
||||||
|
|
||||||
if(nghttp2_is_fatal(rv)) {
|
if(nghttp2_is_fatal(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rv != 0) {
|
if(rv != 0) {
|
||||||
return session_handle_invalid_connection
|
return session_handle_invalid_connection
|
||||||
(session, frame, NGHTTP2_FLOW_CONTROL_ERROR);
|
(session, frame, NGHTTP2_FLOW_CONTROL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
session->remote_settings.initial_window_size = entry->value;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
session->remote_settings[entry->settings_id] = entry->value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!noack) {
|
if(!noack) {
|
||||||
rv = nghttp2_session_add_settings(session, NGHTTP2_FLAG_ACK, NULL, 0);
|
rv = nghttp2_session_add_settings(session, NGHTTP2_FLAG_ACK, NULL, 0);
|
||||||
|
|
||||||
if(rv != 0) {
|
if(rv != 0) {
|
||||||
if(nghttp2_is_fatal(rv)) {
|
if(nghttp2_is_fatal(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
return session_handle_invalid_connection
|
return session_handle_invalid_connection
|
||||||
(session, frame, NGHTTP2_INTERNAL_ERROR);
|
(session, frame, NGHTTP2_INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return session_call_on_frame_received(session, frame);
|
return session_call_on_frame_received(session, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3473,8 +3524,7 @@ int nghttp2_session_on_push_promise_received(nghttp2_session *session,
|
||||||
return session_inflate_handle_invalid_connection
|
return session_inflate_handle_invalid_connection
|
||||||
(session, frame, NGHTTP2_PROTOCOL_ERROR);
|
(session, frame, NGHTTP2_PROTOCOL_ERROR);
|
||||||
}
|
}
|
||||||
if(session->server ||
|
if(session->server || session->local_settings.enable_push == 0) {
|
||||||
session->local_settings[NGHTTP2_SETTINGS_ENABLE_PUSH] == 0) {
|
|
||||||
return session_inflate_handle_invalid_connection
|
return session_inflate_handle_invalid_connection
|
||||||
(session, frame, NGHTTP2_PROTOCOL_ERROR);
|
(session, frame, NGHTTP2_PROTOCOL_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -5580,11 +5630,18 @@ int32_t nghttp2_session_get_stream_remote_window_size(nghttp2_session* session,
|
||||||
uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session,
|
uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session,
|
||||||
nghttp2_settings_id id)
|
nghttp2_settings_id id)
|
||||||
{
|
{
|
||||||
if(id > NGHTTP2_SETTINGS_MAX) {
|
switch(id) {
|
||||||
return 0;
|
case NGHTTP2_SETTINGS_HEADER_TABLE_SIZE:
|
||||||
|
return session->remote_settings.header_table_size;
|
||||||
|
case NGHTTP2_SETTINGS_ENABLE_PUSH:
|
||||||
|
return session->remote_settings.enable_push;
|
||||||
|
case NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS:
|
||||||
|
return session->remote_settings.max_concurrent_streams;
|
||||||
|
case NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:
|
||||||
|
return session->remote_settings.initial_window_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
return session->remote_settings[id];
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nghttp2_session_upgrade(nghttp2_session *session,
|
int nghttp2_session_upgrade(nghttp2_session *session,
|
||||||
|
|
|
@ -106,6 +106,13 @@ typedef struct {
|
||||||
uint8_t raw_sbuf[8];
|
uint8_t raw_sbuf[8];
|
||||||
} nghttp2_inbound_frame;
|
} nghttp2_inbound_frame;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t header_table_size;
|
||||||
|
uint32_t enable_push;
|
||||||
|
uint32_t max_concurrent_streams;
|
||||||
|
uint32_t initial_window_size;
|
||||||
|
} nghttp2_settings_storage;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NGHTTP2_GOAWAY_NONE = 0,
|
NGHTTP2_GOAWAY_NONE = 0,
|
||||||
/* Flag means GOAWAY frame is sent to the remote peer. */
|
/* Flag means GOAWAY frame is sent to the remote peer. */
|
||||||
|
@ -159,10 +166,10 @@ struct nghttp2_session {
|
||||||
in-flight SETTINGS. */
|
in-flight SETTINGS. */
|
||||||
ssize_t inflight_niv;
|
ssize_t inflight_niv;
|
||||||
/* The number of outgoing streams. This will be capped by
|
/* The number of outgoing streams. This will be capped by
|
||||||
remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]. */
|
remote_settings.max_concurrent_streams. */
|
||||||
size_t num_outgoing_streams;
|
size_t num_outgoing_streams;
|
||||||
/* The number of incoming streams. This will be capped by
|
/* The number of incoming streams. This will be capped by
|
||||||
local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]. */
|
local_settings.max_concurrent_streams. */
|
||||||
size_t num_incoming_streams;
|
size_t num_incoming_streams;
|
||||||
/* The number of closed streams still kept in |streams| hash. The
|
/* The number of closed streams still kept in |streams| hash. The
|
||||||
closed streams can be accessed through single linked list
|
closed streams can be accessed through single linked list
|
||||||
|
@ -201,9 +208,9 @@ struct nghttp2_session {
|
||||||
int32_t local_window_size;
|
int32_t local_window_size;
|
||||||
/* Settings value received from the remote endpoint. We just use ID
|
/* Settings value received from the remote endpoint. We just use ID
|
||||||
as index. The index = 0 is unused. */
|
as index. The index = 0 is unused. */
|
||||||
uint32_t remote_settings[NGHTTP2_SETTINGS_MAX+1];
|
nghttp2_settings_storage remote_settings;
|
||||||
/* Settings value of the local endpoint. */
|
/* Settings value of the local endpoint. */
|
||||||
uint32_t local_settings[NGHTTP2_SETTINGS_MAX+1];
|
nghttp2_settings_storage local_settings;
|
||||||
/* Option flags. This is bitwise-OR of 0 or more of nghttp2_optmask. */
|
/* Option flags. This is bitwise-OR of 0 or more of nghttp2_optmask. */
|
||||||
uint32_t opt_flags;
|
uint32_t opt_flags;
|
||||||
/* Unacked local SETTINGS_MAX_CONCURRENT_STREAMS value. We use this
|
/* Unacked local SETTINGS_MAX_CONCURRENT_STREAMS value. We use this
|
||||||
|
|
|
@ -1514,7 +1514,7 @@ void test_nghttp2_session_on_request_headers_received(void)
|
||||||
CU_ASSERT(0 == (session->goaway_flags & NGHTTP2_GOAWAY_FAIL_ON_SEND));
|
CU_ASSERT(0 == (session->goaway_flags & NGHTTP2_GOAWAY_FAIL_ON_SEND));
|
||||||
|
|
||||||
nghttp2_frame_headers_free(&frame.headers);
|
nghttp2_frame_headers_free(&frame.headers);
|
||||||
session->local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] =
|
session->local_settings.max_concurrent_streams =
|
||||||
NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS;
|
NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS;
|
||||||
|
|
||||||
/* Stream ID less than or equal to the previouly received request
|
/* Stream ID less than or equal to the previouly received request
|
||||||
|
@ -1706,7 +1706,7 @@ void test_nghttp2_session_on_push_response_headers_received(void)
|
||||||
|
|
||||||
/* If ACKed max concurrent streams limit is exceeded, GOAWAY is
|
/* If ACKed max concurrent streams limit is exceeded, GOAWAY is
|
||||||
issued */
|
issued */
|
||||||
session->local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] = 1;
|
session->local_settings.max_concurrent_streams = 1;
|
||||||
|
|
||||||
stream = nghttp2_session_open_stream(session, 6, NGHTTP2_STREAM_FLAG_NONE,
|
stream = nghttp2_session_open_stream(session, 6, NGHTTP2_STREAM_FLAG_NONE,
|
||||||
&pri_spec_default,
|
&pri_spec_default,
|
||||||
|
@ -1874,7 +1874,7 @@ void test_nghttp2_session_on_settings_received(void)
|
||||||
|
|
||||||
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
|
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
|
||||||
nghttp2_session_client_new(&session, &callbacks, &user_data);
|
nghttp2_session_client_new(&session, &callbacks, &user_data);
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] = 16*1024;
|
session->remote_settings.initial_window_size = 16*1024;
|
||||||
|
|
||||||
stream1 = nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE,
|
stream1 = nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE,
|
||||||
&pri_spec_default,
|
&pri_spec_default,
|
||||||
|
@ -1891,14 +1891,10 @@ void test_nghttp2_session_on_settings_received(void)
|
||||||
dup_iv(iv, niv), niv);
|
dup_iv(iv, niv), niv);
|
||||||
|
|
||||||
CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0));
|
CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &frame, 0));
|
||||||
CU_ASSERT(1000000009 ==
|
CU_ASSERT(1000000009 == session->remote_settings.max_concurrent_streams);
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]);
|
CU_ASSERT(64*1024 == session->remote_settings.initial_window_size);
|
||||||
CU_ASSERT(64*1024 ==
|
CU_ASSERT(1024 == session->remote_settings.header_table_size);
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]);
|
CU_ASSERT(0 == session->remote_settings.enable_push);
|
||||||
CU_ASSERT(1024 ==
|
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_HEADER_TABLE_SIZE]);
|
|
||||||
CU_ASSERT(0 ==
|
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_ENABLE_PUSH]);
|
|
||||||
|
|
||||||
CU_ASSERT(64*1024 == stream1->remote_window_size);
|
CU_ASSERT(64*1024 == stream1->remote_window_size);
|
||||||
CU_ASSERT(0 == stream2->remote_window_size);
|
CU_ASSERT(0 == stream2->remote_window_size);
|
||||||
|
@ -2102,7 +2098,7 @@ void test_nghttp2_session_on_push_promise_received(void)
|
||||||
&pri_spec_default,
|
&pri_spec_default,
|
||||||
NGHTTP2_STREAM_OPENING, NULL);
|
NGHTTP2_STREAM_OPENING, NULL);
|
||||||
|
|
||||||
session->local_settings[NGHTTP2_SETTINGS_ENABLE_PUSH] = 0;
|
session->local_settings.enable_push = 0;
|
||||||
|
|
||||||
nghttp2_frame_push_promise_init(&frame.push_promise,
|
nghttp2_frame_push_promise_init(&frame.push_promise,
|
||||||
NGHTTP2_FLAG_END_HEADERS, 1, 2,
|
NGHTTP2_FLAG_END_HEADERS, 1, 2,
|
||||||
|
@ -2616,10 +2612,8 @@ void test_nghttp2_session_upgrade(void)
|
||||||
CU_ASSERT(NULL == stream->stream_user_data);
|
CU_ASSERT(NULL == stream->stream_user_data);
|
||||||
CU_ASSERT(NGHTTP2_SHUT_RD == stream->shut_flags);
|
CU_ASSERT(NGHTTP2_SHUT_RD == stream->shut_flags);
|
||||||
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
|
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
|
||||||
CU_ASSERT(1 ==
|
CU_ASSERT(1 == session->remote_settings.max_concurrent_streams);
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]);
|
CU_ASSERT(4095 == session->remote_settings.initial_window_size);
|
||||||
CU_ASSERT(4095 ==
|
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]);
|
|
||||||
/* Call nghttp2_session_upgrade() again is error */
|
/* Call nghttp2_session_upgrade() again is error */
|
||||||
CU_ASSERT(NGHTTP2_ERR_PROTO == nghttp2_session_upgrade(session,
|
CU_ASSERT(NGHTTP2_ERR_PROTO == nghttp2_session_upgrade(session,
|
||||||
settings_payload,
|
settings_payload,
|
||||||
|
@ -3240,9 +3234,9 @@ void test_nghttp2_submit_settings(void)
|
||||||
|
|
||||||
/* Make sure that local settings are not changed */
|
/* Make sure that local settings are not changed */
|
||||||
CU_ASSERT(NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS ==
|
CU_ASSERT(NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS ==
|
||||||
session->local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]);
|
session->local_settings.max_concurrent_streams);
|
||||||
CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE ==
|
CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE ==
|
||||||
session->local_settings[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]);
|
session->local_settings.initial_window_size);
|
||||||
|
|
||||||
/* Now sends without 5th one */
|
/* Now sends without 5th one */
|
||||||
CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 4));
|
CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 4));
|
||||||
|
@ -3271,11 +3265,9 @@ void test_nghttp2_submit_settings(void)
|
||||||
CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &ack_frame, 0));
|
CU_ASSERT(0 == nghttp2_session_on_settings_received(session, &ack_frame, 0));
|
||||||
nghttp2_frame_settings_free(&ack_frame.settings);
|
nghttp2_frame_settings_free(&ack_frame.settings);
|
||||||
|
|
||||||
CU_ASSERT(16*1024 ==
|
CU_ASSERT(16*1024 == session->local_settings.initial_window_size);
|
||||||
session->local_settings[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]);
|
|
||||||
CU_ASSERT(0 == session->hd_inflater.ctx.hd_table_bufsize_max);
|
CU_ASSERT(0 == session->hd_inflater.ctx.hd_table_bufsize_max);
|
||||||
CU_ASSERT(50 ==
|
CU_ASSERT(50 == session->local_settings.max_concurrent_streams);
|
||||||
session->local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]);
|
|
||||||
CU_ASSERT(NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS ==
|
CU_ASSERT(NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS ==
|
||||||
session->pending_local_max_concurrent_stream);
|
session->pending_local_max_concurrent_stream);
|
||||||
|
|
||||||
|
@ -3716,7 +3708,7 @@ void test_nghttp2_session_get_next_ob_item(void)
|
||||||
callbacks.send_callback = null_send_callback;
|
callbacks.send_callback = null_send_callback;
|
||||||
|
|
||||||
nghttp2_session_server_new(&session, &callbacks, NULL);
|
nghttp2_session_server_new(&session, &callbacks, NULL);
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] = 2;
|
session->remote_settings.max_concurrent_streams = 2;
|
||||||
|
|
||||||
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
|
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
|
||||||
nghttp2_submit_ping(session, NGHTTP2_FLAG_NONE, NULL);
|
nghttp2_submit_ping(session, NGHTTP2_FLAG_NONE, NULL);
|
||||||
|
@ -3746,7 +3738,7 @@ void test_nghttp2_session_get_next_ob_item(void)
|
||||||
nghttp2_submit_request(session, &pri_spec, NULL, 0, NULL, NULL);
|
nghttp2_submit_request(session, &pri_spec, NULL, 0, NULL, NULL);
|
||||||
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
|
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
|
||||||
|
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] = 3;
|
session->remote_settings.max_concurrent_streams = 3;
|
||||||
|
|
||||||
CU_ASSERT(NGHTTP2_HEADERS ==
|
CU_ASSERT(NGHTTP2_HEADERS ==
|
||||||
OB_CTRL_TYPE(nghttp2_session_get_next_ob_item(session)));
|
OB_CTRL_TYPE(nghttp2_session_get_next_ob_item(session)));
|
||||||
|
@ -3765,7 +3757,7 @@ void test_nghttp2_session_pop_next_ob_item(void)
|
||||||
callbacks.send_callback = null_send_callback;
|
callbacks.send_callback = null_send_callback;
|
||||||
|
|
||||||
nghttp2_session_server_new(&session, &callbacks, NULL);
|
nghttp2_session_server_new(&session, &callbacks, NULL);
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] = 1;
|
session->remote_settings.max_concurrent_streams = 1;
|
||||||
|
|
||||||
CU_ASSERT(NULL == nghttp2_session_pop_next_ob_item(session));
|
CU_ASSERT(NULL == nghttp2_session_pop_next_ob_item(session));
|
||||||
|
|
||||||
|
@ -3808,7 +3800,7 @@ void test_nghttp2_session_pop_next_ob_item(void)
|
||||||
|
|
||||||
CU_ASSERT(NULL == nghttp2_session_pop_next_ob_item(session));
|
CU_ASSERT(NULL == nghttp2_session_pop_next_ob_item(session));
|
||||||
|
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] = 2;
|
session->remote_settings.max_concurrent_streams = 2;
|
||||||
|
|
||||||
item = nghttp2_session_pop_next_ob_item(session);
|
item = nghttp2_session_pop_next_ob_item(session);
|
||||||
CU_ASSERT(NGHTTP2_HEADERS == OB_CTRL_TYPE(item));
|
CU_ASSERT(NGHTTP2_HEADERS == OB_CTRL_TYPE(item));
|
||||||
|
@ -3819,7 +3811,7 @@ void test_nghttp2_session_pop_next_ob_item(void)
|
||||||
|
|
||||||
/* Check that push reply HEADERS are queued into ob_ss_pq */
|
/* Check that push reply HEADERS are queued into ob_ss_pq */
|
||||||
nghttp2_session_server_new(&session, &callbacks, NULL);
|
nghttp2_session_server_new(&session, &callbacks, NULL);
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] = 0;
|
session->remote_settings.max_concurrent_streams = 0;
|
||||||
nghttp2_session_open_stream(session, 2, NGHTTP2_STREAM_FLAG_NONE,
|
nghttp2_session_open_stream(session, 2, NGHTTP2_STREAM_FLAG_NONE,
|
||||||
&pri_spec_default, NGHTTP2_STREAM_RESERVED,
|
&pri_spec_default, NGHTTP2_STREAM_RESERVED,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -3882,7 +3874,7 @@ void test_nghttp2_session_max_concurrent_streams(void)
|
||||||
CU_ASSERT(0 == nghttp2_session_send(session));
|
CU_ASSERT(0 == nghttp2_session_send(session));
|
||||||
|
|
||||||
/* Check ACKed SETTINGS_MAX_CONCURRENT_STREAMS */
|
/* Check ACKed SETTINGS_MAX_CONCURRENT_STREAMS */
|
||||||
session->local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] = 1;
|
session->local_settings.max_concurrent_streams = 1;
|
||||||
frame.hd.stream_id = 5;
|
frame.hd.stream_id = 5;
|
||||||
|
|
||||||
CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK ==
|
CU_ASSERT(NGHTTP2_ERR_IGN_HEADER_BLOCK ==
|
||||||
|
@ -4067,7 +4059,7 @@ void test_nghttp2_session_flow_control(void)
|
||||||
nghttp2_session_client_new(&session, &callbacks, &ud);
|
nghttp2_session_client_new(&session, &callbacks, &ud);
|
||||||
/* Change it to 64KiB for easy calculation */
|
/* Change it to 64KiB for easy calculation */
|
||||||
session->remote_window_size = 64*1024;
|
session->remote_window_size = 64*1024;
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] = 64*1024;
|
session->remote_settings.initial_window_size = 64*1024;
|
||||||
|
|
||||||
nghttp2_submit_request(session, NULL, NULL, 0, &data_prd, NULL);
|
nghttp2_submit_request(session, NULL, NULL, 0, &data_prd, NULL);
|
||||||
|
|
||||||
|
@ -4097,10 +4089,9 @@ void test_nghttp2_session_flow_control(void)
|
||||||
negative. */
|
negative. */
|
||||||
new_initial_window_size = 16*1024;
|
new_initial_window_size = 16*1024;
|
||||||
stream->remote_window_size = new_initial_window_size-
|
stream->remote_window_size = new_initial_window_size-
|
||||||
(session->remote_settings[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]
|
(session->remote_settings.initial_window_size
|
||||||
- stream->remote_window_size);
|
- stream->remote_window_size);
|
||||||
session->remote_settings[NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] =
|
session->remote_settings.initial_window_size = new_initial_window_size;
|
||||||
new_initial_window_size;
|
|
||||||
CU_ASSERT(-48*1024 == stream->remote_window_size);
|
CU_ASSERT(-48*1024 == stream->remote_window_size);
|
||||||
|
|
||||||
/* Back 48KiB to stream window */
|
/* Back 48KiB to stream window */
|
||||||
|
@ -4565,9 +4556,7 @@ void test_nghttp2_session_set_option(void)
|
||||||
|
|
||||||
nghttp2_session_client_new2(&session, &callbacks, NULL, option);
|
nghttp2_session_client_new2(&session, &callbacks, NULL, option);
|
||||||
|
|
||||||
CU_ASSERT(100 ==
|
CU_ASSERT(100 == session->remote_settings.max_concurrent_streams);
|
||||||
session->
|
|
||||||
remote_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS]);
|
|
||||||
nghttp2_session_del(session);
|
nghttp2_session_del(session);
|
||||||
|
|
||||||
nghttp2_option_del(option);
|
nghttp2_option_del(option);
|
||||||
|
|
Loading…
Reference in New Issue