]> git.kaiwu.me - nginx.git/commitdiff
Adjusted file->sys_offset after the write() syscall.
authorValentin Bartenev <vbart@nginx.com>
Tue, 17 Nov 2015 16:01:41 +0000 (19:01 +0300)
committerValentin Bartenev <vbart@nginx.com>
Tue, 17 Nov 2015 16:01:41 +0000 (19:01 +0300)
This fixes suboptimal behavior caused by surplus lseek() for sequential writes
on systems without pwrite().  A consecutive read after write might result in an
error on systems without pread() and pwrite().

Fortunately, at the moment there are no widely used systems without these
syscalls.

src/os/unix/ngx_files.c

index 417b598f71e765dac2a1882334d2d61dcfdb76d6..36b6b67ca51a2555e61770f2d7be63242deda165 100644 (file)
@@ -226,6 +226,7 @@ ngx_write_file(ngx_file_t *file, u_char *buf, size_t size, off_t offset)
             return NGX_ERROR;
         }
 
+        file->sys_offset += n;
         file->offset += n;
         written += n;