comparison src/core/ngx_output_chain.c @ 2248:1adec90a0e46

disable directio for unaligned reads in Linux
author Igor Sysoev <igor@sysoev.ru>
date Fri, 12 Sep 2008 13:50:12 +0000
parents 8a98616abb73
children 402797ed988a
comparison
equal deleted inserted replaced
2247:981483d63e9f 2248:1adec90a0e46
353 /* 353 /*
354 * we do not set ctx->buf->tag, because we do not want 354 * we do not set ctx->buf->tag, because we do not want
355 * to reuse the buf via ctx->free list 355 * to reuse the buf via ctx->free list
356 */ 356 */
357 357
358 #if (NGX_HAVE_ALIGNED_DIRECTIO)
359 ctx->unaligned = 1;
360 #endif
361
358 return NGX_OK; 362 return NGX_OK;
359 } 363 }
360 364
361 365
362 static ngx_int_t 366 static ngx_int_t
489 dst->flush = src->flush; 493 dst->flush = src->flush;
490 dst->last_buf = src->last_buf; 494 dst->last_buf = src->last_buf;
491 } 495 }
492 496
493 } else { 497 } else {
498
499 #if (NGX_HAVE_ALIGNED_DIRECTIO)
500
501 if (ctx->unaligned) {
502 if (ngx_directio_off(src->file->fd) == -1) {
503 ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, ngx_errno,
504 ngx_directio_off_n " \"%s\" failed",
505 src->file->name.data);
506 }
507 }
508
509 #endif
510
494 n = ngx_read_file(src->file, dst->pos, (size_t) size, src->file_pos); 511 n = ngx_read_file(src->file, dst->pos, (size_t) size, src->file_pos);
512
513 #if (NGX_HAVE_ALIGNED_DIRECTIO)
514
515 if (ctx->unaligned) {
516 ngx_err_t err;
517
518 err = ngx_errno;
519
520 if (ngx_directio_on(src->file->fd) == -1) {
521 ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, ngx_errno,
522 ngx_directio_on_n " \"%s\" failed",
523 src->file->name.data);
524 }
525
526 ngx_set_errno(err);
527
528 ctx->unaligned = 0;
529 }
530
531 #endif
495 532
496 if (n == NGX_ERROR) { 533 if (n == NGX_ERROR) {
497 return (ngx_int_t) n; 534 return (ngx_int_t) n;
498 } 535 }
499 536