mirror of
https://github.com/nginx/nginx.git
synced 2025-06-17 17:20:42 +08:00
SPDY: added the "spdy_chunk_size" directive.
This commit is contained in:
parent
b60700f9e9
commit
8323f317f6
@ -626,6 +626,7 @@ ngx_http_spdy_send_chain(ngx_connection_t *fc, ngx_chain_t *in, off_t limit)
|
|||||||
ngx_chain_t *cl, *out, **ln;
|
ngx_chain_t *cl, *out, **ln;
|
||||||
ngx_http_request_t *r;
|
ngx_http_request_t *r;
|
||||||
ngx_http_spdy_stream_t *stream;
|
ngx_http_spdy_stream_t *stream;
|
||||||
|
ngx_http_spdy_loc_conf_t *slcf;
|
||||||
ngx_http_spdy_out_frame_t *frame;
|
ngx_http_spdy_out_frame_t *frame;
|
||||||
|
|
||||||
r = fc->data;
|
r = fc->data;
|
||||||
@ -664,8 +665,11 @@ ngx_http_spdy_send_chain(ngx_connection_t *fc, ngx_chain_t *in, off_t limit)
|
|||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_size = (limit && limit < NGX_SPDY_MAX_FRAME_SIZE)
|
slcf = ngx_http_get_module_loc_conf(r, ngx_http_spdy_module);
|
||||||
? limit : NGX_SPDY_MAX_FRAME_SIZE;
|
|
||||||
|
frame_size = (limit && limit <= (off_t) slcf->chunk_size)
|
||||||
|
? (size_t) limit
|
||||||
|
: slcf->chunk_size;
|
||||||
|
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
ln = &out;
|
ln = &out;
|
||||||
@ -743,7 +747,7 @@ ngx_http_spdy_send_chain(ngx_connection_t *fc, ngx_chain_t *in, off_t limit)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limit < NGX_SPDY_MAX_FRAME_SIZE) {
|
if (limit < (off_t) slcf->chunk_size) {
|
||||||
frame_size = limit;
|
frame_size = limit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,16 +22,19 @@ static ngx_int_t ngx_http_spdy_module_init(ngx_cycle_t *cycle);
|
|||||||
|
|
||||||
static void *ngx_http_spdy_create_main_conf(ngx_conf_t *cf);
|
static void *ngx_http_spdy_create_main_conf(ngx_conf_t *cf);
|
||||||
static char *ngx_http_spdy_init_main_conf(ngx_conf_t *cf, void *conf);
|
static char *ngx_http_spdy_init_main_conf(ngx_conf_t *cf, void *conf);
|
||||||
|
|
||||||
static void *ngx_http_spdy_create_srv_conf(ngx_conf_t *cf);
|
static void *ngx_http_spdy_create_srv_conf(ngx_conf_t *cf);
|
||||||
static char *ngx_http_spdy_merge_srv_conf(ngx_conf_t *cf, void *parent,
|
static char *ngx_http_spdy_merge_srv_conf(ngx_conf_t *cf, void *parent,
|
||||||
void *child);
|
void *child);
|
||||||
|
static void *ngx_http_spdy_create_loc_conf(ngx_conf_t *cf);
|
||||||
|
static char *ngx_http_spdy_merge_loc_conf(ngx_conf_t *cf, void *parent,
|
||||||
|
void *child);
|
||||||
|
|
||||||
static char *ngx_http_spdy_recv_buffer_size(ngx_conf_t *cf, void *post,
|
static char *ngx_http_spdy_recv_buffer_size(ngx_conf_t *cf, void *post,
|
||||||
void *data);
|
void *data);
|
||||||
static char *ngx_http_spdy_pool_size(ngx_conf_t *cf, void *post, void *data);
|
static char *ngx_http_spdy_pool_size(ngx_conf_t *cf, void *post, void *data);
|
||||||
static char *ngx_http_spdy_streams_index_mask(ngx_conf_t *cf, void *post,
|
static char *ngx_http_spdy_streams_index_mask(ngx_conf_t *cf, void *post,
|
||||||
void *data);
|
void *data);
|
||||||
|
static char *ngx_http_spdy_chunk_size(ngx_conf_t *cf, void *post, void *data);
|
||||||
|
|
||||||
|
|
||||||
static ngx_conf_num_bounds_t ngx_http_spdy_headers_comp_bounds = {
|
static ngx_conf_num_bounds_t ngx_http_spdy_headers_comp_bounds = {
|
||||||
@ -44,6 +47,8 @@ static ngx_conf_post_t ngx_http_spdy_pool_size_post =
|
|||||||
{ ngx_http_spdy_pool_size };
|
{ ngx_http_spdy_pool_size };
|
||||||
static ngx_conf_post_t ngx_http_spdy_streams_index_mask_post =
|
static ngx_conf_post_t ngx_http_spdy_streams_index_mask_post =
|
||||||
{ ngx_http_spdy_streams_index_mask };
|
{ ngx_http_spdy_streams_index_mask };
|
||||||
|
static ngx_conf_post_t ngx_http_spdy_chunk_size_post =
|
||||||
|
{ ngx_http_spdy_chunk_size };
|
||||||
|
|
||||||
|
|
||||||
static ngx_command_t ngx_http_spdy_commands[] = {
|
static ngx_command_t ngx_http_spdy_commands[] = {
|
||||||
@ -97,6 +102,13 @@ static ngx_command_t ngx_http_spdy_commands[] = {
|
|||||||
offsetof(ngx_http_spdy_srv_conf_t, headers_comp),
|
offsetof(ngx_http_spdy_srv_conf_t, headers_comp),
|
||||||
&ngx_http_spdy_headers_comp_bounds },
|
&ngx_http_spdy_headers_comp_bounds },
|
||||||
|
|
||||||
|
{ ngx_string("spdy_chunk_size"),
|
||||||
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
||||||
|
ngx_conf_set_size_slot,
|
||||||
|
NGX_HTTP_LOC_CONF_OFFSET,
|
||||||
|
offsetof(ngx_http_spdy_loc_conf_t, chunk_size),
|
||||||
|
&ngx_http_spdy_chunk_size_post },
|
||||||
|
|
||||||
ngx_null_command
|
ngx_null_command
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -111,8 +123,8 @@ static ngx_http_module_t ngx_http_spdy_module_ctx = {
|
|||||||
ngx_http_spdy_create_srv_conf, /* create server configuration */
|
ngx_http_spdy_create_srv_conf, /* create server configuration */
|
||||||
ngx_http_spdy_merge_srv_conf, /* merge server configuration */
|
ngx_http_spdy_merge_srv_conf, /* merge server configuration */
|
||||||
|
|
||||||
NULL, /* create location configuration */
|
ngx_http_spdy_create_loc_conf, /* create location configuration */
|
||||||
NULL /* merge location configuration */
|
ngx_http_spdy_merge_loc_conf /* merge location configuration */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -296,6 +308,34 @@ ngx_http_spdy_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void *
|
||||||
|
ngx_http_spdy_create_loc_conf(ngx_conf_t *cf)
|
||||||
|
{
|
||||||
|
ngx_http_spdy_loc_conf_t *slcf;
|
||||||
|
|
||||||
|
slcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_spdy_loc_conf_t));
|
||||||
|
if (slcf == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
slcf->chunk_size = NGX_CONF_UNSET_SIZE;
|
||||||
|
|
||||||
|
return slcf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *
|
||||||
|
ngx_http_spdy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
||||||
|
{
|
||||||
|
ngx_http_spdy_loc_conf_t *prev = parent;
|
||||||
|
ngx_http_spdy_loc_conf_t *conf = child;
|
||||||
|
|
||||||
|
ngx_conf_merge_size_value(conf->chunk_size, prev->chunk_size, 8 * 1024);
|
||||||
|
|
||||||
|
return NGX_CONF_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
ngx_http_spdy_recv_buffer_size(ngx_conf_t *cf, void *post, void *data)
|
ngx_http_spdy_recv_buffer_size(ngx_conf_t *cf, void *post, void *data)
|
||||||
{
|
{
|
||||||
@ -349,3 +389,22 @@ ngx_http_spdy_streams_index_mask(ngx_conf_t *cf, void *post, void *data)
|
|||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *
|
||||||
|
ngx_http_spdy_chunk_size(ngx_conf_t *cf, void *post, void *data)
|
||||||
|
{
|
||||||
|
size_t *sp = data;
|
||||||
|
|
||||||
|
if (*sp == 0) {
|
||||||
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||||
|
"the spdy chunk size cannot be zero");
|
||||||
|
return NGX_CONF_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*sp > NGX_SPDY_MAX_FRAME_SIZE) {
|
||||||
|
*sp = NGX_SPDY_MAX_FRAME_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NGX_CONF_OK;
|
||||||
|
}
|
||||||
|
@ -30,6 +30,11 @@ typedef struct {
|
|||||||
} ngx_http_spdy_srv_conf_t;
|
} ngx_http_spdy_srv_conf_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
size_t chunk_size;
|
||||||
|
} ngx_http_spdy_loc_conf_t;
|
||||||
|
|
||||||
|
|
||||||
extern ngx_module_t ngx_http_spdy_module;
|
extern ngx_module_t ngx_http_spdy_module;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user