Mercurial > hg > nginx
comparison src/http/ngx_http_write_filter.c @ 257:70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 11 Feb 2004 17:08:49 +0000 |
parents | fd9fecc4193f |
children | 87e73f067470 |
comparison
equal
deleted
inserted
replaced
256:8e39cab6abd5 | 257:70e1c7d2b83d |
---|---|
4 #include <ngx_event.h> | 4 #include <ngx_event.h> |
5 #include <ngx_http.h> | 5 #include <ngx_http.h> |
6 | 6 |
7 | 7 |
8 typedef struct { | 8 typedef struct { |
9 ssize_t buffer_output; | 9 ssize_t postpone_output; |
10 } ngx_http_write_filter_conf_t; | 10 } ngx_http_write_filter_conf_t; |
11 | 11 |
12 | 12 |
13 typedef struct { | 13 typedef struct { |
14 ngx_chain_t *out; | 14 ngx_chain_t *out; |
21 static int ngx_http_write_filter_init(ngx_cycle_t *cycle); | 21 static int ngx_http_write_filter_init(ngx_cycle_t *cycle); |
22 | 22 |
23 | 23 |
24 static ngx_command_t ngx_http_write_filter_commands[] = { | 24 static ngx_command_t ngx_http_write_filter_commands[] = { |
25 | 25 |
26 /* STUB */ | |
26 { ngx_string("buffer_output"), | 27 { ngx_string("buffer_output"), |
27 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 28 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
28 ngx_conf_set_size_slot, | 29 ngx_conf_set_size_slot, |
29 NGX_HTTP_LOC_CONF_OFFSET, | 30 NGX_HTTP_LOC_CONF_OFFSET, |
30 offsetof(ngx_http_write_filter_conf_t, buffer_output), | 31 offsetof(ngx_http_write_filter_conf_t, postpone_output), |
32 NULL }, | |
33 | |
34 { ngx_string("postpone_output"), | |
35 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
36 ngx_conf_set_size_slot, | |
37 NGX_HTTP_LOC_CONF_OFFSET, | |
38 offsetof(ngx_http_write_filter_conf_t, postpone_output), | |
31 NULL }, | 39 NULL }, |
32 | 40 |
33 ngx_null_command | 41 ngx_null_command |
34 }; | 42 }; |
35 | 43 |
110 if (cl->hunk->type & NGX_HUNK_LAST) { | 118 if (cl->hunk->type & NGX_HUNK_LAST) { |
111 last = 1; | 119 last = 1; |
112 } | 120 } |
113 } | 121 } |
114 | 122 |
115 #if (NGX_DEBUG_WRITE_FILTER) | 123 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
116 ngx_log_debug(r->connection->log, | 124 "http write filter: l:%d f:" OFF_T_FMT " s:" OFF_T_FMT, |
117 "write filter: last:%d flush:%qd size:%qd" _ | 125 last, flush, size); |
118 last _ flush _ size); | |
119 #endif | |
120 | 126 |
121 conf = ngx_http_get_module_loc_conf(r->main ? r->main : r, | 127 conf = ngx_http_get_module_loc_conf(r->main ? r->main : r, |
122 ngx_http_write_filter_module); | 128 ngx_http_write_filter_module); |
123 | 129 |
124 /* | 130 /* |
125 * avoid the output if there is no last hunk, no flush point and | 131 * avoid the output if there is no last hunk, no flush point and |
126 * the size of the hunks is smaller than "buffer_output" directive | 132 * the size of the hunks is smaller than "postpone_output" directive |
127 */ | 133 */ |
128 | 134 |
129 if (!last && flush == 0 && size < conf->buffer_output) { | 135 if (!last && flush == 0 && size < conf->postpone_output) { |
130 return NGX_OK; | 136 return NGX_OK; |
131 } | 137 } |
132 | 138 |
133 if (r->connection->write->delayed) { | 139 if (r->connection->write->delayed) { |
134 return NGX_AGAIN; | 140 return NGX_AGAIN; |
138 return NGX_OK; | 144 return NGX_OK; |
139 } | 145 } |
140 | 146 |
141 chain = ngx_write_chain(r->connection, ctx->out); | 147 chain = ngx_write_chain(r->connection, ctx->out); |
142 | 148 |
143 #if (NGX_DEBUG_WRITE_FILTER) | 149 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
144 ngx_log_debug(r->connection->log, "write filter %x" _ chain); | 150 "http write filter %X", chain); |
145 #endif | |
146 | 151 |
147 if (chain == NGX_CHAIN_ERROR) { | 152 if (chain == NGX_CHAIN_ERROR) { |
148 return NGX_ERROR; | 153 return NGX_ERROR; |
149 } | 154 } |
150 | 155 |
164 | 169 |
165 ngx_test_null(conf, | 170 ngx_test_null(conf, |
166 ngx_palloc(cf->pool, sizeof(ngx_http_write_filter_conf_t)), | 171 ngx_palloc(cf->pool, sizeof(ngx_http_write_filter_conf_t)), |
167 NULL); | 172 NULL); |
168 | 173 |
169 conf->buffer_output = NGX_CONF_UNSET; | 174 conf->postpone_output = NGX_CONF_UNSET; |
170 | 175 |
171 return conf; | 176 return conf; |
172 } | 177 } |
173 | 178 |
174 | 179 |
176 void *parent, void *child) | 181 void *parent, void *child) |
177 { | 182 { |
178 ngx_http_write_filter_conf_t *prev = parent; | 183 ngx_http_write_filter_conf_t *prev = parent; |
179 ngx_http_write_filter_conf_t *conf = child; | 184 ngx_http_write_filter_conf_t *conf = child; |
180 | 185 |
181 ngx_conf_merge_size_value(conf->buffer_output, prev->buffer_output, 1460); | 186 ngx_conf_merge_size_value(conf->postpone_output, prev->postpone_output, |
187 1460); | |
182 | 188 |
183 return NULL; | 189 return NULL; |
184 } | 190 } |
185 | 191 |
186 | 192 |