comparison src/core/ngx_output_chain.c @ 8782:eaf356a35f5d quic

Merged with the default branch.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 29 Dec 2021 15:17:26 +0300
parents b002ad258f1d
children
comparison
equal deleted inserted replaced
8768:32daba3aabb2 8782:eaf356a35f5d
27 #define NGX_NONE 1 27 #define NGX_NONE 1
28 28
29 29
30 static ngx_inline ngx_int_t 30 static ngx_inline ngx_int_t
31 ngx_output_chain_as_is(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf); 31 ngx_output_chain_as_is(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf);
32 #if (NGX_HAVE_AIO_SENDFILE)
33 static ngx_int_t ngx_output_chain_aio_setup(ngx_output_chain_ctx_t *ctx,
34 ngx_file_t *file);
35 #endif
36 static ngx_int_t ngx_output_chain_add_copy(ngx_pool_t *pool, 32 static ngx_int_t ngx_output_chain_add_copy(ngx_pool_t *pool,
37 ngx_chain_t **chain, ngx_chain_t *in); 33 ngx_chain_t **chain, ngx_chain_t *in);
38 static ngx_int_t ngx_output_chain_align_file_buf(ngx_output_chain_ctx_t *ctx, 34 static ngx_int_t ngx_output_chain_align_file_buf(ngx_output_chain_ctx_t *ctx,
39 off_t bsize); 35 off_t bsize);
40 static ngx_int_t ngx_output_chain_get_buf(ngx_output_chain_ctx_t *ctx, 36 static ngx_int_t ngx_output_chain_get_buf(ngx_output_chain_ctx_t *ctx,
258 buf->file->thread_handler = ctx->thread_handler; 254 buf->file->thread_handler = ctx->thread_handler;
259 buf->file->thread_ctx = ctx->filter_ctx; 255 buf->file->thread_ctx = ctx->filter_ctx;
260 } 256 }
261 #endif 257 #endif
262 258
263 if (buf->in_file && buf->file->directio) {
264 return 0;
265 }
266
267 sendfile = ctx->sendfile; 259 sendfile = ctx->sendfile;
268 260
269 #if (NGX_SENDFILE_LIMIT) 261 #if (NGX_SENDFILE_LIMIT)
270 262
271 if (buf->in_file && buf->file_pos >= NGX_SENDFILE_LIMIT) { 263 if (buf->in_file && buf->file_pos >= NGX_SENDFILE_LIMIT) {
272 sendfile = 0; 264 sendfile = 0;
273 } 265 }
274 266
275 #endif 267 #endif
276 268
269 #if !(NGX_HAVE_SENDFILE_NODISKIO)
270
271 /*
272 * With DIRECTIO, disable sendfile() unless sendfile(SF_NOCACHE)
273 * is available.
274 */
275
276 if (buf->in_file && buf->file->directio) {
277 sendfile = 0;
278 }
279
280 #endif
281
277 if (!sendfile) { 282 if (!sendfile) {
278 283
279 if (!ngx_buf_in_memory(buf)) { 284 if (!ngx_buf_in_memory(buf)) {
280 return 0; 285 return 0;
281 } 286 }
282 287
283 buf->in_file = 0; 288 buf->in_file = 0;
284 } 289 }
285 290
286 #if (NGX_HAVE_AIO_SENDFILE)
287 if (ctx->aio_preload && buf->in_file) {
288 (void) ngx_output_chain_aio_setup(ctx, buf->file);
289 }
290 #endif
291
292 if (ctx->need_in_memory && !ngx_buf_in_memory(buf)) { 291 if (ctx->need_in_memory && !ngx_buf_in_memory(buf)) {
293 return 0; 292 return 0;
294 } 293 }
295 294
296 if (ctx->need_in_temp && (buf->memory || buf->mmap)) { 295 if (ctx->need_in_temp && (buf->memory || buf->mmap)) {
297 return 0; 296 return 0;
298 } 297 }
299 298
300 return 1; 299 return 1;
301 } 300 }
302
303
304 #if (NGX_HAVE_AIO_SENDFILE)
305
306 static ngx_int_t
307 ngx_output_chain_aio_setup(ngx_output_chain_ctx_t *ctx, ngx_file_t *file)
308 {
309 ngx_event_aio_t *aio;
310
311 if (file->aio == NULL && ngx_file_aio_init(file, ctx->pool) != NGX_OK) {
312 return NGX_ERROR;
313 }
314
315 aio = file->aio;
316
317 aio->data = ctx->filter_ctx;
318 aio->preload_handler = ctx->aio_preload;
319
320 return NGX_OK;
321 }
322
323 #endif
324 301
325 302
326 static ngx_int_t 303 static ngx_int_t
327 ngx_output_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain, 304 ngx_output_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain,
328 ngx_chain_t *in) 305 ngx_chain_t *in)