comparison src/stream/ngx_stream.c @ 6694:ea9dfe2f62e7

Stream: preread phase. In this phase, head of a stream is read and analysed before proceeding to the content phase. Amount of data read is controlled by the module implementing the phase, but not more than defined by the "preread_buffer_size" directive. The time spent on processing preread is controlled by the "preread_timeout" directive. The typical preread phase module will parse the beginning of a stream and set variable that may be used by the content phase, for example to make routing decision.
author Vladimir Homutov <vl@nginx.com>
date Thu, 15 Sep 2016 14:56:02 +0300
parents 3908156a51fa
children cebf5fed00bf
comparison
equal deleted inserted replaced
6693:3908156a51fa 6694:ea9dfe2f62e7
300 { 300 {
301 return NGX_ERROR; 301 return NGX_ERROR;
302 } 302 }
303 #endif 303 #endif
304 304
305 if (ngx_array_init(&cmcf->phases[NGX_STREAM_PREREAD_PHASE].handlers,
306 cf->pool, 1, sizeof(ngx_stream_handler_pt))
307 != NGX_OK)
308 {
309 return NGX_ERROR;
310 }
311
305 if (ngx_array_init(&cmcf->phases[NGX_STREAM_LOG_PHASE].handlers, 312 if (ngx_array_init(&cmcf->phases[NGX_STREAM_LOG_PHASE].handlers,
306 cf->pool, 1, sizeof(ngx_stream_handler_pt)) 313 cf->pool, 1, sizeof(ngx_stream_handler_pt))
307 != NGX_OK) 314 != NGX_OK)
308 { 315 {
309 return NGX_ERROR; 316 return NGX_ERROR;
340 347
341 for (i = 0; i < NGX_STREAM_LOG_PHASE; i++) { 348 for (i = 0; i < NGX_STREAM_LOG_PHASE; i++) {
342 h = cmcf->phases[i].handlers.elts; 349 h = cmcf->phases[i].handlers.elts;
343 350
344 switch (i) { 351 switch (i) {
352
353 case NGX_STREAM_PREREAD_PHASE:
354 checker = ngx_stream_core_preread_phase;
355 break;
345 356
346 case NGX_STREAM_CONTENT_PHASE: 357 case NGX_STREAM_CONTENT_PHASE:
347 ph->checker = ngx_stream_core_content_phase; 358 ph->checker = ngx_stream_core_content_phase;
348 n++; 359 n++;
349 ph++; 360 ph++;