Mercurial > hg > nginx
comparison src/http/ngx_http_spdy_module.c @ 5515:e5fb14e85040
SPDY: added the "spdy_chunk_size" directive.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Tue, 14 Jan 2014 16:24:45 +0400 |
parents | c0f7b94e88ba |
children | 39d7eef2e332 |
comparison
equal
deleted
inserted
replaced
5514:b7ee1bae0ffa | 5515:e5fb14e85040 |
---|---|
20 | 20 |
21 static ngx_int_t ngx_http_spdy_module_init(ngx_cycle_t *cycle); | 21 static ngx_int_t ngx_http_spdy_module_init(ngx_cycle_t *cycle); |
22 | 22 |
23 static void *ngx_http_spdy_create_main_conf(ngx_conf_t *cf); | 23 static void *ngx_http_spdy_create_main_conf(ngx_conf_t *cf); |
24 static char *ngx_http_spdy_init_main_conf(ngx_conf_t *cf, void *conf); | 24 static char *ngx_http_spdy_init_main_conf(ngx_conf_t *cf, void *conf); |
25 | |
26 static void *ngx_http_spdy_create_srv_conf(ngx_conf_t *cf); | 25 static void *ngx_http_spdy_create_srv_conf(ngx_conf_t *cf); |
27 static char *ngx_http_spdy_merge_srv_conf(ngx_conf_t *cf, void *parent, | 26 static char *ngx_http_spdy_merge_srv_conf(ngx_conf_t *cf, void *parent, |
27 void *child); | |
28 static void *ngx_http_spdy_create_loc_conf(ngx_conf_t *cf); | |
29 static char *ngx_http_spdy_merge_loc_conf(ngx_conf_t *cf, void *parent, | |
28 void *child); | 30 void *child); |
29 | 31 |
30 static char *ngx_http_spdy_recv_buffer_size(ngx_conf_t *cf, void *post, | 32 static char *ngx_http_spdy_recv_buffer_size(ngx_conf_t *cf, void *post, |
31 void *data); | 33 void *data); |
32 static char *ngx_http_spdy_pool_size(ngx_conf_t *cf, void *post, void *data); | 34 static char *ngx_http_spdy_pool_size(ngx_conf_t *cf, void *post, void *data); |
33 static char *ngx_http_spdy_streams_index_mask(ngx_conf_t *cf, void *post, | 35 static char *ngx_http_spdy_streams_index_mask(ngx_conf_t *cf, void *post, |
34 void *data); | 36 void *data); |
37 static char *ngx_http_spdy_chunk_size(ngx_conf_t *cf, void *post, void *data); | |
35 | 38 |
36 | 39 |
37 static ngx_conf_num_bounds_t ngx_http_spdy_headers_comp_bounds = { | 40 static ngx_conf_num_bounds_t ngx_http_spdy_headers_comp_bounds = { |
38 ngx_conf_check_num_bounds, 0, 9 | 41 ngx_conf_check_num_bounds, 0, 9 |
39 }; | 42 }; |
42 { ngx_http_spdy_recv_buffer_size }; | 45 { ngx_http_spdy_recv_buffer_size }; |
43 static ngx_conf_post_t ngx_http_spdy_pool_size_post = | 46 static ngx_conf_post_t ngx_http_spdy_pool_size_post = |
44 { ngx_http_spdy_pool_size }; | 47 { ngx_http_spdy_pool_size }; |
45 static ngx_conf_post_t ngx_http_spdy_streams_index_mask_post = | 48 static ngx_conf_post_t ngx_http_spdy_streams_index_mask_post = |
46 { ngx_http_spdy_streams_index_mask }; | 49 { ngx_http_spdy_streams_index_mask }; |
50 static ngx_conf_post_t ngx_http_spdy_chunk_size_post = | |
51 { ngx_http_spdy_chunk_size }; | |
47 | 52 |
48 | 53 |
49 static ngx_command_t ngx_http_spdy_commands[] = { | 54 static ngx_command_t ngx_http_spdy_commands[] = { |
50 | 55 |
51 { ngx_string("spdy_recv_buffer_size"), | 56 { ngx_string("spdy_recv_buffer_size"), |
95 ngx_conf_set_num_slot, | 100 ngx_conf_set_num_slot, |
96 NGX_HTTP_SRV_CONF_OFFSET, | 101 NGX_HTTP_SRV_CONF_OFFSET, |
97 offsetof(ngx_http_spdy_srv_conf_t, headers_comp), | 102 offsetof(ngx_http_spdy_srv_conf_t, headers_comp), |
98 &ngx_http_spdy_headers_comp_bounds }, | 103 &ngx_http_spdy_headers_comp_bounds }, |
99 | 104 |
105 { ngx_string("spdy_chunk_size"), | |
106 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
107 ngx_conf_set_size_slot, | |
108 NGX_HTTP_LOC_CONF_OFFSET, | |
109 offsetof(ngx_http_spdy_loc_conf_t, chunk_size), | |
110 &ngx_http_spdy_chunk_size_post }, | |
111 | |
100 ngx_null_command | 112 ngx_null_command |
101 }; | 113 }; |
102 | 114 |
103 | 115 |
104 static ngx_http_module_t ngx_http_spdy_module_ctx = { | 116 static ngx_http_module_t ngx_http_spdy_module_ctx = { |
109 ngx_http_spdy_init_main_conf, /* init main configuration */ | 121 ngx_http_spdy_init_main_conf, /* init main configuration */ |
110 | 122 |
111 ngx_http_spdy_create_srv_conf, /* create server configuration */ | 123 ngx_http_spdy_create_srv_conf, /* create server configuration */ |
112 ngx_http_spdy_merge_srv_conf, /* merge server configuration */ | 124 ngx_http_spdy_merge_srv_conf, /* merge server configuration */ |
113 | 125 |
114 NULL, /* create location configuration */ | 126 ngx_http_spdy_create_loc_conf, /* create location configuration */ |
115 NULL /* merge location configuration */ | 127 ngx_http_spdy_merge_loc_conf /* merge location configuration */ |
116 }; | 128 }; |
117 | 129 |
118 | 130 |
119 ngx_module_t ngx_http_spdy_module = { | 131 ngx_module_t ngx_http_spdy_module = { |
120 NGX_MODULE_V1, | 132 NGX_MODULE_V1, |
294 | 306 |
295 return NGX_CONF_OK; | 307 return NGX_CONF_OK; |
296 } | 308 } |
297 | 309 |
298 | 310 |
311 static void * | |
312 ngx_http_spdy_create_loc_conf(ngx_conf_t *cf) | |
313 { | |
314 ngx_http_spdy_loc_conf_t *slcf; | |
315 | |
316 slcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_spdy_loc_conf_t)); | |
317 if (slcf == NULL) { | |
318 return NULL; | |
319 } | |
320 | |
321 slcf->chunk_size = NGX_CONF_UNSET_SIZE; | |
322 | |
323 return slcf; | |
324 } | |
325 | |
326 | |
327 static char * | |
328 ngx_http_spdy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
329 { | |
330 ngx_http_spdy_loc_conf_t *prev = parent; | |
331 ngx_http_spdy_loc_conf_t *conf = child; | |
332 | |
333 ngx_conf_merge_size_value(conf->chunk_size, prev->chunk_size, 8 * 1024); | |
334 | |
335 return NGX_CONF_OK; | |
336 } | |
337 | |
338 | |
299 static char * | 339 static char * |
300 ngx_http_spdy_recv_buffer_size(ngx_conf_t *cf, void *post, void *data) | 340 ngx_http_spdy_recv_buffer_size(ngx_conf_t *cf, void *post, void *data) |
301 { | 341 { |
302 size_t *sp = data; | 342 size_t *sp = data; |
303 | 343 |
347 | 387 |
348 *np = mask; | 388 *np = mask; |
349 | 389 |
350 return NGX_CONF_OK; | 390 return NGX_CONF_OK; |
351 } | 391 } |
392 | |
393 | |
394 static char * | |
395 ngx_http_spdy_chunk_size(ngx_conf_t *cf, void *post, void *data) | |
396 { | |
397 size_t *sp = data; | |
398 | |
399 if (*sp == 0) { | |
400 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
401 "the spdy chunk size cannot be zero"); | |
402 return NGX_CONF_ERROR; | |
403 } | |
404 | |
405 if (*sp > NGX_SPDY_MAX_FRAME_SIZE) { | |
406 *sp = NGX_SPDY_MAX_FRAME_SIZE; | |
407 } | |
408 | |
409 return NGX_CONF_OK; | |
410 } |