Browse Source

stipped data. from chunk structure (belongs to the last changeset)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@704 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.6
Jan Kneschke 17 years ago
parent
commit
88c96e46a0
  1. 24
      src/network_freebsd_sendfile.c
  2. 20
      src/network_openssl.c
  3. 22
      src/network_solaris_sendfilev.c

24
src/network_freebsd_sendfile.c

@ -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;
}

20
src/network_openssl.c

@ -58,13 +58,13 @@ int network_write_chunkqueue_openssl(server *srv, connection *con, chunkqueue *c
size_t toSend;
ssize_t r;
if (c->data.mem->used == 0) {
if (c->mem->used == 0) {
chunk_finished = 1;
break;
}
offset = c->data.mem->ptr + c->offset;
toSend = c->data.mem->used - 1 - c->offset;
offset = c->mem->ptr + c->offset;
toSend = c->mem->used - 1 - c->offset;
/**
* SSL_write man-page
@ -125,7 +125,7 @@ int network_write_chunkqueue_openssl(server *srv, connection *con, chunkqueue *c
con->bytes_written += r;
}
if (c->offset == (off_t)c->data.mem->used - 1) {
if (c->offset == (off_t)c->mem->used - 1) {
chunk_finished = 1;
}
@ -140,9 +140,9 @@ int network_write_chunkqueue_openssl(server *srv, connection *con, chunkqueue *c
int ifd;
int write_wait = 0;
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;
}
@ -153,12 +153,12 @@ int network_write_chunkqueue_openssl(server *srv, connection *con, chunkqueue *c
do {
offset = c->data.file.offset + c->offset;
toSend = c->data.file.length - c->offset;
offset = c->file.offset + c->offset;
toSend = c->file.length - c->offset;
if (toSend > LOCAL_SEND_BUFSIZE) toSend = LOCAL_SEND_BUFSIZE;
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;
@ -210,7 +210,7 @@ int network_write_chunkqueue_openssl(server *srv, connection *con, chunkqueue *c
con->bytes_written += r;
}
if (c->offset == c->data.file.length) {
if (c->offset == c->file.length) {
chunk_finished = 1;
}
} while(!chunk_finished && !write_wait);

22
src/network_solaris_sendfilev.c

@ -68,12 +68,12 @@ int network_write_chunkqueue_solarissendfilev(server *srv, connection *con, chun
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;
@ -147,22 +147,22 @@ int network_write_chunkqueue_solarissendfilev(server *srv, connection *con, chun
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;
toSend = c->data.file.length - c->offset;
offset = c->file.offset + c->offset;
toSend = 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;
@ -189,7 +189,7 @@ int network_write_chunkqueue_solarissendfilev(server *srv, connection *con, chun
c->offset += written;
con->bytes_written += written;
if (c->offset == c->data.file.length) {
if (c->offset == c->file.length) {
chunk_finished = 1;
}

Loading…
Cancel
Save