Browse Source

[core] revert increase of temp file size back to 1MB, provide a configure option "server.upload-temp-file-size" instead (fixes #2680)

From: Stefan Bühler <stbuehler@web.de>

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3050 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.38
Stefan Bühler 6 years ago
parent
commit
a069548370
  1. 1
      NEWS
  2. 1
      src/base.h
  3. 20
      src/chunk.c
  4. 7
      src/chunk.h
  5. 3
      src/configfile.c
  6. 5
      src/connections.c

1
NEWS

@ -13,6 +13,7 @@ NEWS
* add force_assert for many allocations and function results
* [mod_secdownload] use a hopefully constant time comparison to check hash (fixes #2679)
* [config] check config option scope; warn if server option is given in conditional
* [core] revert increase of temp file size back to 1MB, provide a configure option "server.upload-temp-file-size" instead (fixes #2680)
- 1.4.37 - 2015-08-30
* [mod_proxy] remove debug log line from error log (fixes #2659)

1
src/base.h

@ -508,6 +508,7 @@ typedef struct {
buffer *network_backend;
array *modules;
array *upload_tempdirs;
unsigned int upload_temp_file_size;
unsigned short max_worker;
unsigned short max_fds;

20
src/chunk.c

@ -332,9 +332,10 @@ void chunkqueue_use_memory(chunkqueue *cq, size_t len) {
}
}
void chunkqueue_set_tempdirs(chunkqueue *cq, array *tempdirs) {
void chunkqueue_set_tempdirs(chunkqueue *cq, array *tempdirs, unsigned int upload_temp_file_size) {
force_assert(NULL != cq);
cq->tempdirs = tempdirs;
cq->upload_temp_file_size = upload_temp_file_size;
}
void chunkqueue_steal(chunkqueue *dest, chunkqueue *src, off_t len) {
@ -425,17 +426,24 @@ static chunk *chunkqueue_get_append_tempfile(chunkqueue *cq) {
return c;
}
/* default 1MB, upper limit 128MB */
#define DEFAULT_TEMPFILE_SIZE (1 * 1024 * 1024)
#define MAX_TEMPFILE_SIZE (128 * 1024 * 1024)
static int chunkqueue_append_to_tempfile(server *srv, chunkqueue *dest, const char *mem, size_t len) {
/* copy everything to max MAX_TEMPFILE_SIZE sized tempfiles */
static const off_t MAX_TEMPFILE_SIZE = 16 * 1024 * 1024; /* 16MB */
/* copy everything to max max_tempfile_size sized tempfiles */
const off_t max_tempfile_size
= (0 == dest->upload_temp_file_size) ? DEFAULT_TEMPFILE_SIZE
: (dest->upload_temp_file_size > MAX_TEMPFILE_SIZE) ? MAX_TEMPFILE_SIZE
: dest->upload_temp_file_size;
chunk *dst_c = NULL;
ssize_t written;
/*
* if the last chunk is
* - smaller than MAX_TEMPFILE_SIZE
* - smaller than max_tempfile_size
* - not read yet (offset == 0)
* -> append to it (so it might actually become larger than MAX_TEMPFILE_SIZE)
* -> append to it (so it might actually become larger than max_tempfile_size)
* otherwise
* -> create a new chunk
*
@ -449,7 +457,7 @@ static int chunkqueue_append_to_tempfile(server *srv, chunkqueue *dest, const ch
/* ok, take the last chunk for our job */
dst_c = dest->last;
if (dest->last->file.length >= MAX_TEMPFILE_SIZE) {
if (dest->last->file.length >= max_tempfile_size) {
/* the chunk is too large now, close it */
if (-1 != dst_c->file.fd) {
close(dst_c->file.fd);

7
src/chunk.h

@ -41,13 +41,14 @@ typedef struct {
chunk *unused;
size_t unused_chunks;
array *tempdirs;
off_t bytes_in, bytes_out;
off_t bytes_in, bytes_out;
array *tempdirs;
unsigned int upload_temp_file_size;
} chunkqueue;
chunkqueue *chunkqueue_init(void);
void chunkqueue_set_tempdirs(chunkqueue *cq, array *tempdirs);
void chunkqueue_set_tempdirs(chunkqueue *cq, array *tempdirs, unsigned int upload_temp_file_size);
void chunkqueue_append_file(chunkqueue *cq, buffer *fn, off_t offset, off_t len); /* copies "fn" */
void chunkqueue_append_mem(chunkqueue *cq, const char *mem, size_t len); /* copies memory */
void chunkqueue_append_buffer(chunkqueue *cq, buffer *mem); /* may reset "mem" */

3
src/configfile.c

@ -107,6 +107,7 @@ static int config_insert(server *srv) {
{ "ssl.disable-client-renegotiation", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 65 */
{ "ssl.honor-cipher-order", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 66 */
{ "ssl.empty-fragments", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 67 */
{ "server.upload-temp-file-size", NULL, T_CONFIG_INT, T_CONFIG_SCOPE_SERVER }, /* 68 */
{ "server.host",
"use server.bind instead",
@ -169,6 +170,8 @@ static int config_insert(server *srv) {
cv[52].destination = &(srv->srvconf.reject_expect_100_with_417);
cv[55].destination = srv->srvconf.breakagelog_file;
cv[68].destination = &(srv->srvconf.upload_temp_file_size);
srv->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *));
force_assert(srv->config_storage);

5
src/connections.c

@ -689,7 +689,10 @@ connection *connection_init(server *srv) {
con->write_queue = chunkqueue_init();
con->read_queue = chunkqueue_init();
con->request_content_queue = chunkqueue_init();
chunkqueue_set_tempdirs(con->request_content_queue, srv->srvconf.upload_tempdirs);
chunkqueue_set_tempdirs(
con->request_content_queue,
srv->srvconf.upload_tempdirs,
srv->srvconf.upload_temp_file_size);
con->request.headers = array_init();
con->response.headers = array_init();

Loading…
Cancel
Save