nginx-0.0.1-2003-10-22-11:05:29 import
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c
index 9ed378d..adafc17 100644
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -77,15 +77,15 @@
         ce = ce->next;
     }
 
-    if (lseek(file->fd, offset, SEEK_SET) == -1) {
-        ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno, "lseek() failed");
-        return NGX_ERROR;
+    if (file->offset != offset) {
+        if (lseek(file->fd, offset, SEEK_SET) == -1) {
+            ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno, "lseek() failed");
+            return NGX_ERROR;
+        }
     }
 
     n = writev(file->fd, (struct iovec *) io.elts, io.nelts);
 
-    ngx_destroy_array(&io);
-
     if (n == -1) {
         ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno, "writev() failed");
         return NGX_ERROR;
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c
index 1632424..093265a 100644
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -83,9 +83,9 @@
 
         if (ce && (ce->hunk->type & NGX_HUNK_FILE)) {
             file = ce->hunk;
-            ce = ce->next;
             fsize = (size_t) (file->file_last - file->file_pos);
             fprev = file->file_last;
+            ce = ce->next;
 
             /* coalesce the neighbouring file hunks */