comparison src/core/ngx_output_chain.c @ 194:2357fa41738a

nginx-0.0.1-2003-11-21-09:30:49 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 21 Nov 2003 06:30:49 +0000
parents c42be4185301
children 70e1c7d2b83d
comparison
equal deleted inserted replaced
193:dd66383796a5 194:2357fa41738a
8 8
9 9
10 ngx_inline static int ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, 10 ngx_inline static int ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx,
11 ngx_hunk_t *hunk); 11 ngx_hunk_t *hunk);
12 static int ngx_output_chain_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src, 12 static int ngx_output_chain_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src,
13 int sendfile); 13 u_int sendfile);
14 14
15 15
16 int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in) 16 int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
17 { 17 {
18 int rc, last; 18 int rc, last;
19 size_t hsize; 19 size_t size, hsize;
20 ssize_t size;
21 ngx_chain_t *cl, *out, **last_out; 20 ngx_chain_t *cl, *out, **last_out;
22 21
23 /* 22 /*
24 * the short path for the case when the chain ctx->in is empty 23 * the short path for the case when the chain ctx->in is empty
25 * and the incoming chain is empty too or it has the single hunk 24 * and the incoming chain is empty too or it has the single hunk
189 return 0; 188 return 0;
190 } 189 }
191 190
192 191
193 static int ngx_output_chain_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src, 192 static int ngx_output_chain_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src,
194 int sendfile) 193 u_int sendfile)
195 { 194 {
196 ssize_t n, size; 195 size_t size;
196 ssize_t n;
197 197
198 size = ngx_hunk_size(src); 198 size = ngx_hunk_size(src);
199 199
200 if (size > (dst->end - dst->pos)) { 200 if (size > (size_t) (dst->end - dst->pos)) {
201 size = dst->end - dst->pos; 201 size = dst->end - dst->pos;
202 } 202 }
203 203
204 if (src->type & NGX_HUNK_IN_MEMORY) { 204 if (src->type & NGX_HUNK_IN_MEMORY) {
205 ngx_memcpy(dst->pos, src->pos, size); 205 ngx_memcpy(dst->pos, src->pos, size);
231 if (n == NGX_AGAIN) { 231 if (n == NGX_AGAIN) {
232 return n; 232 return n;
233 } 233 }
234 #endif 234 #endif
235 235
236 if (n != size) { 236 if ((size_t) n != size) {
237 ngx_log_error(NGX_LOG_ALERT, src->file->log, 0, 237 ngx_log_error(NGX_LOG_ALERT, src->file->log, 0,
238 ngx_read_file_n " reads only %d of %d from file", 238 ngx_read_file_n " reads only %d of %d from file",
239 n, size); 239 n, size);
240 if (n == 0) { 240 if (n == 0) {
241 return NGX_ERROR; 241 return NGX_ERROR;