diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2016-07-28 03:57:52 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2016-07-28 03:57:52 -0400 |
commit | c8e647ad3199de63d05489a89ef4e27aadc1e280 (patch) | |
tree | 547b05a6813049fc0693e434b4ebadd2e2b9f0cf /src/chunk.c | |
parent | a62bff986657f8143a34a8f11478c6e054f2a0ed (diff) | |
download | lighttpd-git-c8e647ad3199de63d05489a89ef4e27aadc1e280.tar.gz |
[core] set chunkqueue tempdirs at startup
If server.upload-dirs is not configured, then attempt to use TMPDIR
from the environment, if set, or else use /tmp. Warn at startup if
tempdirs are not present.
Diffstat (limited to 'src/chunk.c')
-rw-r--r-- | src/chunk.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/chunk.c b/src/chunk.c index 2bb57c3a..a6b1f1f0 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -22,6 +22,13 @@ #include <errno.h> #include <string.h> +/* default 1MB, upper limit 128MB */ +#define DEFAULT_TEMPFILE_SIZE (1 * 1024 * 1024) +#define MAX_TEMPFILE_SIZE (128 * 1024 * 1024) + +static array *chunkqueue_default_tempdirs = NULL; +static unsigned int chunkqueue_default_tempfile_size = DEFAULT_TEMPFILE_SIZE; + chunkqueue *chunkqueue_init(void) { chunkqueue *cq; @@ -33,6 +40,9 @@ chunkqueue *chunkqueue_init(void) { cq->unused = NULL; + cq->tempdirs = chunkqueue_default_tempdirs; + cq->upload_temp_file_size = chunkqueue_default_tempfile_size; + return cq; } @@ -377,10 +387,15 @@ void chunkqueue_use_memory(chunkqueue *cq, size_t len) { } } -/* default 1MB, upper limit 128MB */ -#define DEFAULT_TEMPFILE_SIZE (1 * 1024 * 1024) -#define MAX_TEMPFILE_SIZE (128 * 1024 * 1024) +void chunkqueue_set_tempdirs_default (array *tempdirs, unsigned int upload_temp_file_size) { + chunkqueue_default_tempdirs = tempdirs; + chunkqueue_default_tempfile_size + = (0 == upload_temp_file_size) ? DEFAULT_TEMPFILE_SIZE + : (upload_temp_file_size > MAX_TEMPFILE_SIZE) ? MAX_TEMPFILE_SIZE + : upload_temp_file_size; +} +#if 0 void chunkqueue_set_tempdirs(chunkqueue *cq, array *tempdirs, unsigned int upload_temp_file_size) { force_assert(NULL != cq); cq->tempdirs = tempdirs; @@ -390,6 +405,7 @@ void chunkqueue_set_tempdirs(chunkqueue *cq, array *tempdirs, unsigned int uploa : upload_temp_file_size; cq->tempdir_idx = 0; } +#endif void chunkqueue_steal(chunkqueue *dest, chunkqueue *src, off_t len) { while (len > 0) { |