diff --git a/src/chunk.c b/src/chunk.c index 1722bf48..61aae1f7 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -170,7 +170,7 @@ int chunkqueue_append_file(chunkqueue *cq, buffer *fn, off_t offset, off_t len) c->type = FILE_CHUNK; buffer_copy_string_buffer(c->file.name, fn); - c->file.offset = offset; + c->file.start = offset; c->file.length = len; c->offset = 0; diff --git a/src/chunk.h b/src/chunk.h index 3609e4d9..c65c3b11 100644 --- a/src/chunk.h +++ b/src/chunk.h @@ -4,36 +4,31 @@ #include "buffer.h" typedef struct chunk { - /* - * MEM_CHUNK - * b: the chunk it self - * FILE_CHUNK - * b: a buffer for the filename - */ - enum { UNUSED_CHUNK, MEM_CHUNK, FILE_CHUNK } type; - /* memchunk */ - buffer *mem; /* it might be large */ + buffer *mem; /* either the storage of the mem-chunk or the read-ahead buffer */ struct { /* filechunk */ - buffer *name; - off_t offset; - off_t length; + buffer *name; /* name of the file */ + off_t start; /* starting offset in the file */ + off_t length; /* octets to send from the starting offset */ int fd; struct { - char *start; - size_t length; + char *start; /* the start pointer of the mmap'ed area */ + size_t length; /* size of the mmap'ed area */ + off_t offset; /* start is octet away from the start of the file */ } mmap; - int is_temp; + int is_temp; /* file is temporary and will be deleted if on cleanup */ } file; - /* how many bytes are already handled */ - - off_t offset; + off_t offset; /* octets sent from this chunk + the size of the chunk is either + - mem-chunk: mem->used - 1 + - file-chunk: file.length + */ struct chunk *next; } chunk; diff --git a/src/network_freebsd_sendfile.c b/src/network_freebsd_sendfile.c index 53c6746a..a6994c01 100644 --- a/src/network_freebsd_sendfile.c +++ b/src/network_freebsd_sendfile.c @@ -143,7 +143,7 @@ int network_write_chunkqueue_freebsdsendfile(server *srv, connection *con, int f return -1; } - offset = c->file.offset + c->offset; + offset = c->file.start + c->offset; /* limit the toSend to 2^31-1 bytes in a chunk */ toSend = c->file.length - c->offset > ((1 << 30) - 1) ? ((1 << 30) - 1) : c->file.length - c->offset; diff --git a/src/network_linux_sendfile.c b/src/network_linux_sendfile.c index d7f5e86d..5628a94e 100644 --- a/src/network_linux_sendfile.c +++ b/src/network_linux_sendfile.c @@ -134,7 +134,7 @@ int network_write_chunkqueue_linuxsendfile(server *srv, connection *con, int fd, return -1; } - offset = c->file.offset + c->offset; + offset = c->file.start + c->offset; /* limit the toSend to 2^31-1 bytes in a chunk */ toSend = c->file.length - c->offset > ((1 << 30) - 1) ? ((1 << 30) - 1) : c->file.length - c->offset; diff --git a/src/network_openssl.c b/src/network_openssl.c index 9de75309..3a0b492d 100644 --- a/src/network_openssl.c +++ b/src/network_openssl.c @@ -157,7 +157,7 @@ int network_write_chunkqueue_openssl(server *srv, connection *con, SSL *ssl, chu do { - offset = c->file.offset + c->offset; + offset = c->file.start + c->offset; toSend = c->file.length - c->offset; if (toSend > LOCAL_SEND_BUFSIZE) toSend = LOCAL_SEND_BUFSIZE; diff --git a/src/network_solaris_sendfilev.c b/src/network_solaris_sendfilev.c index 9c4ca625..0ab669f0 100644 --- a/src/network_solaris_sendfilev.c +++ b/src/network_solaris_sendfilev.c @@ -151,7 +151,7 @@ int network_write_chunkqueue_solarissendfilev(server *srv, connection *con, int return -1; } - offset = c->file.offset + c->offset; + offset = c->file.start + c->offset; toSend = c->file.length - c->offset; if (offset > sce->st.st_size) { diff --git a/src/network_write.c b/src/network_write.c index 177e90b6..90fc2ac9 100644 --- a/src/network_write.c +++ b/src/network_write.c @@ -83,7 +83,7 @@ int network_write_chunkqueue_write(server *srv, connection *con, int fd, chunkqu return -1; } - offset = c->file.offset + c->offset; + offset = c->file.start + c->offset; toSend = c->file.length - c->offset; if (offset > sce->st.st_size) {