diff src/os/unix/ngx_linux_sendfile_chain.c @ 196:11fbd0fc041d

nginx-0.0.1-2003-11-26-18:42:18 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 26 Nov 2003 15:42:18 +0000
parents 8dee38ea9117
children 34995c5ec6c4
line wrap: on
line diff
--- 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(ng
 {
     int              rc;
     char            *prev;
-    off_t            fprev;
+    off_t            offset;
     size_t           size, fsize, sent;
     ngx_int_t        use_cork, eintr;
     struct iovec    *iov;
@@ -16,7 +16,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ng
     ngx_hunk_t      *file;
     ngx_array_t      header;
     ngx_event_t     *wev;
-    ngx_chain_t     *cl;
+    ngx_chain_t     *cl, *tail;
 
     wev = c->write;
 
@@ -24,8 +24,6 @@ ngx_chain_t *ngx_linux_sendfile_chain(ng
         return in;
     }
 
-    cork = 0;
-
     do {
         file = NULL;
         fsize = 0;
@@ -84,20 +82,20 @@ ngx_log_debug(c->log, "CORK");
 
             file = cl->hunk;
             fsize = (size_t) (file->file_last - file->file_pos);
-            fprev = file->file_last;
+            offset = 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
-                    || fprev != cl->hunk->file_pos)
+                    || offset != cl->hunk->file_pos)
                 {
                     break;
                 }
 
                 fsize += (size_t) (cl->hunk->file_last - cl->hunk->file_pos);
-                fprev = cl->hunk->file_last;
+                offset = cl->hunk->file_last;
                 cl = cl->next;
             }
         }
@@ -110,7 +108,8 @@ ngx_log_debug(c->log, "CORK");
         tail = cl;
 
         if (fsize) {
-            rc = sendfile(c->fd, file->file->fd, file->file_pos, fsize);
+            offset = file->file_pos;
+            rc = sendfile(c->fd, file->file->fd, &offset, fsize);
 
             if (rc == -1) {
                 err = ngx_errno;