Hi<br> I read the code in src/os/ngx_files.c, function ngx_write_file, but get a little confused<br> <i style="color: rgb(255, 0, 0);"> for ( ;; ) {<br> n = pwrite(file->fd, buf, size, offset);<br><br>
if (n == -1) {<br> ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,<br> "pwrite() \"%s\" failed", file->name.data);<br> return NGX_ERROR;<br>
}<br><br> file->offset += n;<br> written += n;<br><br> if ((size_t) n == size) {<br> return written;<br> }<br><br> offset += n;<br> size -= n;<br> }<br>
</i><span style="color: rgb(255, 0, 0);"> <font color="#000000">the code seems want to write all content in buf to file(file->fd), but I think </font></span><i style="color: rgb(255, 0, 0);">n = pwrite(file->fd, buf, size,
offset) </i><span style="color: rgb(0, 0, 0);">should be changed to</span><i style="color: rgb(255, 0, 0);"> </i><i style="color: rgb(255, 0, 0);">n = pwrite(file->fd, buf+written, size,
offset);<br><span style="color: rgb(0, 0, 0);"> man pwrite:<br> </span></i><i style="color: rgb(0, 0, 0);">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.</i><i style="color: rgb(255, 0, 0);"><br>
<br><br></i>