comparison src/core/ngx_output_chain.c @ 2129:25add486e7aa

directio
author Igor Sysoev <igor@sysoev.ru>
date Wed, 30 Jul 2008 12:34:04 +0000
parents 3091e5d770a6
children 61a09532e310
comparison
equal deleted inserted replaced
2128:345a014436d4 2129:25add486e7aa
30 { 30 {
31 off_t bsize; 31 off_t bsize;
32 size_t size; 32 size_t size;
33 ngx_int_t rc, last; 33 ngx_int_t rc, last;
34 ngx_uint_t recycled; 34 ngx_uint_t recycled;
35 ngx_buf_t *b;
35 ngx_chain_t *cl, *out, **last_out; 36 ngx_chain_t *cl, *out, **last_out;
36 37
37 if (ctx->in == NULL && ctx->busy == NULL) { 38 if (ctx->in == NULL && ctx->busy == NULL) {
38 39
39 /* 40 /*
159 size = (size_t) bsize; 160 size = (size_t) bsize;
160 recycled = 0; 161 recycled = 0;
161 } 162 }
162 } 163 }
163 164
164 ctx->buf = ngx_create_temp_buf(ctx->pool, size); 165 b = ngx_calloc_buf(ctx->pool);
165 if (ctx->buf == NULL) { 166 if (b == NULL) {
166 return NGX_ERROR; 167 return NGX_ERROR;
167 } 168 }
168 169
169 ctx->buf->tag = ctx->tag; 170 /*
170 ctx->buf->recycled = recycled; 171 * allocate block aligned to a disk sector size
172 * to enable O_DIRECT
173 */
174
175 b->start = ngx_pmemalign(ctx->pool, size, 512);
176 if (b->start == NULL) {
177 return NGX_ERROR;
178 }
179
180 b->pos = b->start;
181 b->last = b->start;
182 b->end = b->last + size;
183 b->temporary = 1;
184 b->tag = ctx->tag;
185 b->recycled = recycled;
186
187 ctx->buf = b;
171 ctx->allocated++; 188 ctx->allocated++;
172 } 189 }
173 } 190 }
174 191
175 rc = ngx_output_chain_copy_buf(ctx->buf, ctx->in->buf, 192 rc = ngx_output_chain_copy_buf(ctx->buf, ctx->in->buf,