Mercurial > hg > nginx
comparison src/os/unix/ngx_linux_sendfile_chain.c @ 5918:c50b5ed3cd4b
Fixed type of sendfile() return value on Linux.
There was no real problem since the amount of bytes can be sent is limited by
NGX_SENDFILE_MAXSIZE to less than 2G. But that can be changed in the future
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Wed, 19 Nov 2014 21:18:13 +0300 |
parents | 2c64b69daec5 |
children | c901f2764c27 |
comparison
equal
deleted
inserted
replaced
5917:2c64b69daec5 | 5918:c50b5ed3cd4b |
---|---|
28 | 28 |
29 | 29 |
30 ngx_chain_t * | 30 ngx_chain_t * |
31 ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) | 31 ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) |
32 { | 32 { |
33 int rc, tcp_nodelay; | 33 int tcp_nodelay; |
34 off_t send, prev_send, sent; | 34 off_t send, prev_send, sent; |
35 size_t file_size; | 35 size_t file_size; |
36 ssize_t n; | 36 ssize_t n; |
37 ngx_err_t err; | 37 ngx_err_t err; |
38 ngx_buf_t *file; | 38 ngx_buf_t *file; |
168 #endif | 168 #endif |
169 | 169 |
170 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, | 170 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
171 "sendfile: @%O %uz", file->file_pos, file_size); | 171 "sendfile: @%O %uz", file->file_pos, file_size); |
172 | 172 |
173 rc = sendfile(c->fd, file->file->fd, &offset, file_size); | 173 n = sendfile(c->fd, file->file->fd, &offset, file_size); |
174 | 174 |
175 if (rc == -1) { | 175 if (n == -1) { |
176 err = ngx_errno; | 176 err = ngx_errno; |
177 | 177 |
178 switch (err) { | 178 switch (err) { |
179 case NGX_EAGAIN: | 179 case NGX_EAGAIN: |
180 break; | 180 break; |
191 | 191 |
192 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, | 192 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, |
193 "sendfile() is not ready"); | 193 "sendfile() is not ready"); |
194 } | 194 } |
195 | 195 |
196 sent = rc > 0 ? rc : 0; | 196 sent = n > 0 ? n : 0; |
197 | 197 |
198 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, | 198 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
199 "sendfile: %d, @%O %O:%uz", | 199 "sendfile: %z, @%O %O:%uz", |
200 rc, file->file_pos, sent, file_size); | 200 n, file->file_pos, sent, file_size); |
201 | 201 |
202 } else { | 202 } else { |
203 n = ngx_writev(c, &header); | 203 n = ngx_writev(c, &header); |
204 | 204 |
205 if (n == NGX_ERROR) { | 205 if (n == NGX_ERROR) { |