bug in function ngx_write_file?
lu wenbin
luwenbin84 at gmail.com
Wed Jun 30 07:26:46 MSD 2010
Hi
I read the code in src/os/ngx_files.c, function ngx_write_file, but
get a little confused
* for ( ;; ) {
n = pwrite(file->fd, buf, size, offset);
if (n == -1) {
ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
"pwrite() \"%s\" failed", file->name.data);
return NGX_ERROR;
}
file->offset += n;
written += n;
if ((size_t) n == size) {
return written;
}
offset += n;
size -= n;
}
* the code seems want to write all content in buf to file(file->fd), but
I think *n = pwrite(file->fd, buf, size, offset) *should be changed to* **n
= pwrite(file->fd, buf+written, size, offset);
man pwrite:
**pwrite() writes up to count bytes from the buffer starting at buf
to the file descriptor fd at offset offset. The file offset is not
changed.**
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx-devel/attachments/20100630/e54429d3/attachment-0001.html>
More information about the nginx-devel
mailing list