diff options
Diffstat (limited to 'src/libfast')
-rw-r--r-- | src/libfast/Makefile.in | 12 | ||||
-rw-r--r-- | src/libfast/fast_request.c | 39 |
2 files changed, 20 insertions, 31 deletions
diff --git a/src/libfast/Makefile.in b/src/libfast/Makefile.in index 032385431..dbfb9889b 100644 --- a/src/libfast/Makefile.in +++ b/src/libfast/Makefile.in @@ -219,8 +219,6 @@ BTLIB = @BTLIB@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CHECK_CFLAGS = @CHECK_CFLAGS@ -CHECK_LIBS = @CHECK_LIBS@ COVERAGE_CFLAGS = @COVERAGE_CFLAGS@ COVERAGE_LDFLAGS = @COVERAGE_LDFLAGS@ CPP = @CPP@ @@ -288,6 +286,11 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREADLIB = @PTHREADLIB@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RTLIB = @RTLIB@ RUBY = @RUBY@ @@ -376,12 +379,16 @@ pcsclite_CFLAGS = @pcsclite_CFLAGS@ pcsclite_LIBS = @pcsclite_LIBS@ pdfdir = @pdfdir@ piddir = @piddir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ pki_plugins = @pki_plugins@ plugindir = @plugindir@ pool_plugins = @pool_plugins@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ random_device = @random_device@ resolv_conf = @resolv_conf@ routing_table = @routing_table@ @@ -396,6 +403,7 @@ soup_LIBS = @soup_LIBS@ srcdir = @srcdir@ starter_plugins = @starter_plugins@ strongswan_conf = @strongswan_conf@ +strongswan_options = @strongswan_options@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ t_plugins = @t_plugins@ diff --git a/src/libfast/fast_request.c b/src/libfast/fast_request.c index 0673750b7..a56a59167 100644 --- a/src/libfast/fast_request.c +++ b/src/libfast/fast_request.c @@ -23,7 +23,6 @@ #include <pthread.h> #include <string.h> #include <unistd.h> -#include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> @@ -294,31 +293,17 @@ METHOD(fast_request_t, serve, void, METHOD(fast_request_t, sendfile, bool, private_fast_request_t *this, char *path, char *mime) { - struct stat sb; - chunk_t data; - void *addr; - int fd, written; + chunk_t *data; + int written; char buf[24]; - fd = open(path, O_RDONLY); - if (fd == -1) + data = chunk_map(path, FALSE); + if (!data) { return FALSE; } - if (fstat(fd, &sb) == -1) - { - close(fd); - return FALSE; - } - addr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (addr == MAP_FAILED) - { - close(fd); - return FALSE; - } - /* FCGX does not like large integers, print to a buffer using libc */ - snprintf(buf, sizeof(buf), "%lld", (int64_t)sb.st_size); + snprintf(buf, sizeof(buf), "%lld", (int64_t)data->len); FCGX_FPrintF(this->req.out, "Content-Length: %s\n", buf); if (mime) { @@ -326,22 +311,18 @@ METHOD(fast_request_t, sendfile, bool, } FCGX_FPrintF(this->req.out, "\n"); - data = chunk_create(addr, sb.st_size); - - while (data.len) + while (data->len) { - written = FCGX_PutStr(data.ptr, data.len, this->req.out); + written = FCGX_PutStr(data->ptr, data->len, this->req.out); if (written == -1) { - munmap(addr, sb.st_size); - close(fd); + chunk_unmap(data); return FALSE; } - data = chunk_skip(data, written); + *data = chunk_skip(*data, written); } - munmap(addr, sb.st_size); - close(fd); + chunk_unmap(data); return TRUE; } |