summaryrefslogtreecommitdiffhomepage
path: root/src/stream/ngx_stream.c
diff options
context:
space:
mode:
authorVladimir Homutov <vl@nginx.com>2016-09-15 14:56:02 +0300
committerVladimir Homutov <vl@nginx.com>2016-09-15 14:56:02 +0300
commit704446127e310d8b0a4e9d5ddf655d5684846fce (patch)
treef27efe1175a27a05d8d541893536d9eb4e921cf9 /src/stream/ngx_stream.c
parent05a455ff21aa7afd938bd45444e5d9c6d42b6c4c (diff)
downloadnginx-704446127e310d8b0a4e9d5ddf655d5684846fce.tar.gz
nginx-704446127e310d8b0a4e9d5ddf655d5684846fce.tar.bz2
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.
Diffstat (limited to 'src/stream/ngx_stream.c')
-rw-r--r--src/stream/ngx_stream.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/stream/ngx_stream.c b/src/stream/ngx_stream.c
index 9aed0a879..7312c3e2e 100644
--- a/src/stream/ngx_stream.c
+++ b/src/stream/ngx_stream.c
@@ -302,6 +302,13 @@ ngx_stream_init_phases(ngx_conf_t *cf, ngx_stream_core_main_conf_t *cmcf)
}
#endif
+ if (ngx_array_init(&cmcf->phases[NGX_STREAM_PREREAD_PHASE].handlers,
+ cf->pool, 1, sizeof(ngx_stream_handler_pt))
+ != NGX_OK)
+ {
+ return NGX_ERROR;
+ }
+
if (ngx_array_init(&cmcf->phases[NGX_STREAM_LOG_PHASE].handlers,
cf->pool, 1, sizeof(ngx_stream_handler_pt))
!= NGX_OK)
@@ -343,6 +350,10 @@ ngx_stream_init_phase_handlers(ngx_conf_t *cf,
switch (i) {
+ case NGX_STREAM_PREREAD_PHASE:
+ checker = ngx_stream_core_preread_phase;
+ break;
+
case NGX_STREAM_CONTENT_PHASE:
ph->checker = ngx_stream_core_content_phase;
n++;