Browse Source

ported to stat-cache

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@598 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.2
Jan Kneschke 17 years ago
parent
commit
6f940eaeb7
  1. 22
      src/network_solaris_sendfilev.c

22
src/network_solaris_sendfilev.c

@ -22,7 +22,7 @@
#include "network.h"
#include "fdevent.h"
#include "log.h"
#include "file_cache.h"
#include "stat_cache.h"
#ifndef UIO_MAXIOV
#define UIO_MAXIOV IOV_MAX
@ -147,23 +147,31 @@ int network_write_chunkqueue_solarissendfilev(server *srv, connection *con, chun
off_t offset;
size_t toSend, written;
sendfilevec_t fvec;
stat_cache_entry *sce = NULL;
int ifd;
if (HANDLER_GO_ON != file_cache_get_entry(srv, con, c->data.file.name, &(con->fce))) {
if (HANDLER_ERROR == stat_cache_get_entry(srv, con, c->data.file.name, &sce)) {
log_error_write(srv, __FILE__, __LINE__, "sb",
strerror(errno), c->data.file.name);
return -1;
}
offset = c->data.file.offset + c->offset;
toSend = c->data.file.length - c->offset;
if (offset > con->fce->st.st_size) {
if (offset > sce->st.st_size) {
log_error_write(srv, __FILE__, __LINE__, "sb", "file was shrinked:", c->data.file.name);
return -1;
}
fvec.sfv_fd = con->fce->fd;
if (-1 == (ifd = open(c->data.file.name->ptr, O_RDONLY))) {
log_error_write(srv, __FILE__, __LINE__, "ss", "open failed: ", strerror(errno));
return -1;
}
fvec.sfv_fd = ifd;
fvec.sfv_flag = 0;
fvec.sfv_off = offset;
fvec.sfv_len = toSend;
@ -173,12 +181,14 @@ int network_write_chunkqueue_solarissendfilev(server *srv, connection *con, chun
if (errno != EAGAIN) {
log_error_write(srv, __FILE__, __LINE__, "ssd", "sendfile: ", strerror(errno), errno);
close(ifd);
return -1;
}
r = 0;
}
close(ifd);
c->offset += written;
con->bytes_written += written;

Loading…
Cancel
Save