Browse Source

fixed SIGBUS in range-requests as we were mmaping/madvising too much

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@838 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.8
Jan Kneschke 16 years ago
parent
commit
87cfee3fc5
  1. 10
      src/network_writev.c

10
src/network_writev.c

@ -204,10 +204,9 @@ int network_write_chunkqueue_writev(server *srv, connection *con, int fd, chunkq
* 3. use non-blocking IO for file-transfers
* */
/* all mmap()ed areas are 16Mbyte expect the last which might be smaller */
off_t we_want_to_send = c->file.length - c->offset + c->file.start;
size_t to_mmap = (we_want_to_send < we_want_to_mmap) ? we_want_to_send : we_want_to_mmap;
/* all mmap()ed areas are 512kb expect the last which might be smaller */
off_t we_want_to_send;
size_t to_mmap;
/* this is a remap, move the mmap-offset */
if (c->file.mmap.start != MAP_FAILED) {
@ -222,6 +221,9 @@ int network_write_chunkqueue_writev(server *srv, connection *con, int fd, chunkq
}
}
we_want_to_send = c->file.length - c->offset + c->file.start - c->file.mmap.offset;
to_mmap = (we_want_to_send < we_want_to_mmap) ? we_want_to_send : we_want_to_mmap;
if (-1 == c->file.fd) { /* open the file if not already open */
if (-1 == (c->file.fd = open(c->file.name->ptr, O_RDONLY))) {
log_error_write(srv, __FILE__, __LINE__, "sbs", "open failed for:", c->file.name, strerror(errno));

Loading…
Cancel
Save