|
|
|
@ -60,12 +60,12 @@ int network_write_chunkqueue_freebsdsendfile(server *srv, connection *con, chunk
|
|
|
|
|
for(num_chunks = 0, tc = c; tc && tc->type == MEM_CHUNK && num_chunks < UIO_MAXIOV; num_chunks++, tc = tc->next); |
|
|
|
|
|
|
|
|
|
for(tc = c, i = 0; i < num_chunks; tc = tc->next, i++) { |
|
|
|
|
if (tc->data.mem->used == 0) { |
|
|
|
|
chunks[i].iov_base = tc->data.mem->ptr; |
|
|
|
|
if (tc->mem->used == 0) { |
|
|
|
|
chunks[i].iov_base = tc->mem->ptr; |
|
|
|
|
chunks[i].iov_len = 0; |
|
|
|
|
} else { |
|
|
|
|
offset = tc->data.mem->ptr + tc->offset; |
|
|
|
|
toSend = tc->data.mem->used - 1 - tc->offset; |
|
|
|
|
offset = tc->mem->ptr + tc->offset; |
|
|
|
|
toSend = tc->mem->used - 1 - tc->offset; |
|
|
|
|
|
|
|
|
|
chunks[i].iov_base = offset; |
|
|
|
|
|
|
|
|
@ -139,24 +139,24 @@ int network_write_chunkqueue_freebsdsendfile(server *srv, connection *con, chunk
|
|
|
|
|
stat_cache_entry *sce = NULL; |
|
|
|
|
int ifd; |
|
|
|
|
|
|
|
|
|
if (HANDLER_ERROR == stat_cache_get_entry(srv, con, c->data.file.name, &sce)) { |
|
|
|
|
if (HANDLER_ERROR == stat_cache_get_entry(srv, con, c->file.name, &sce)) { |
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "sb", |
|
|
|
|
strerror(errno), c->data.file.name); |
|
|
|
|
strerror(errno), c->file.name); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
offset = c->data.file.offset + c->offset; |
|
|
|
|
offset = c->file.offset + c->offset; |
|
|
|
|
/* limit the toSend to 2^31-1 bytes in a chunk */ |
|
|
|
|
toSend = c->data.file.length - c->offset > ((1 << 30) - 1) ?
|
|
|
|
|
((1 << 30) - 1) : c->data.file.length - c->offset; |
|
|
|
|
toSend = c->file.length - c->offset > ((1 << 30) - 1) ?
|
|
|
|
|
((1 << 30) - 1) : c->file.length - c->offset; |
|
|
|
|
|
|
|
|
|
if (offset > sce->st.st_size) { |
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "sb", "file was shrinked:", c->data.file.name); |
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "sb", "file was shrinked:", c->file.name); |
|
|
|
|
|
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (-1 == (ifd = open(c->data.file.name->ptr, O_RDONLY))) { |
|
|
|
|
if (-1 == (ifd = open(c->file.name->ptr, O_RDONLY))) { |
|
|
|
|
log_error_write(srv, __FILE__, __LINE__, "ss", "open failed: ", strerror(errno)); |
|
|
|
|
|
|
|
|
|
return -1; |
|
|
|
@ -183,7 +183,7 @@ int network_write_chunkqueue_freebsdsendfile(server *srv, connection *con, chunk
|
|
|
|
|
c->offset += r; |
|
|
|
|
con->bytes_written += r; |
|
|
|
|
|
|
|
|
|
if (c->offset == c->data.file.length) { |
|
|
|
|
if (c->offset == c->file.length) { |
|
|
|
|
chunk_finished = 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|