comparison src/os/unix/ngx_files.c @ 6298:8f6d753c1953

Adjusted file->sys_offset after the write() syscall. 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.
author Valentin Bartenev <vbart@nginx.com>
date Tue, 17 Nov 2015 19:01:41 +0300
parents 387696b36c29
children 5170c3040ce1
comparison
equal deleted inserted replaced
6297:92482faf5d8a 6298:8f6d753c1953
224 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno, 224 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
225 "write() \"%s\" failed", file->name.data); 225 "write() \"%s\" failed", file->name.data);
226 return NGX_ERROR; 226 return NGX_ERROR;
227 } 227 }
228 228
229 file->sys_offset += n;
229 file->offset += n; 230 file->offset += n;
230 written += n; 231 written += n;
231 232
232 if ((size_t) n == size) { 233 if ((size_t) n == size) {
233 return written; 234 return written;