aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_linux_sendfile_chain.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/unix/ngx_linux_sendfile_chain.c')
-rw-r--r--src/os/unix/ngx_linux_sendfile_chain.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c
index 0b8e41792..9b311b21e 100644
--- a/src/os/unix/ngx_linux_sendfile_chain.c
+++ b/src/os/unix/ngx_linux_sendfile_chain.c
@@ -8,7 +8,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in)
{
int rc;
char *prev;
- off_t offset;
+ off_t fprev;
size_t size, fsize, sent;
ngx_int_t use_cork, eintr;
struct iovec *iov;
@@ -17,6 +17,11 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in)
ngx_array_t header;
ngx_event_t *wev;
ngx_chain_t *cl, *tail;
+#if (HAVE_SENDFILE64)
+ off_t offset;
+#else
+ int32_t offset;
+#endif
wev = c->write;
@@ -82,20 +87,20 @@ ngx_log_debug(c->log, "CORK");
file = cl->hunk;
fsize = (size_t) (file->file_last - file->file_pos);
- offset = file->file_last;
+ fprev = file->file_last;
cl = cl->next;
/* coalesce the neighbouring file hunks */
while (cl && (cl->hunk->type & NGX_HUNK_FILE)) {
if (file->file->fd != cl->hunk->file->fd
- || offset != cl->hunk->file_pos)
+ || fprev != cl->hunk->file_pos)
{
break;
}
fsize += (size_t) (cl->hunk->file_last - cl->hunk->file_pos);
- offset = cl->hunk->file_last;
+ fprev = cl->hunk->file_last;
cl = cl->next;
}
}
@@ -108,7 +113,11 @@ ngx_log_debug(c->log, "CORK");
tail = cl;
if (fsize) {
+#if (HAVE_SENDFILE64)
offset = file->file_pos;
+#else
+ offset = (int32_t) file->file_pos;
+#endif
rc = sendfile(c->fd, file->file->fd, &offset, fsize);
if (rc == -1) {