chunkqueue can get a list of tempdirs which are tried to open a file at
server.upload-dirs is the option in the configfile git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@812 152afb58-edef-0310-8abb-c4023f1b3aa9
This commit is contained in:
parent
308e5ce017
commit
9404220490
2
NEWS
2
NEWS
|
@ -12,13 +12,13 @@ NEWS
|
|||
* added better compat to Apache for ?auto in mod_status
|
||||
* added support for userdirs without a entry in /etc/passwd in mod_userdir
|
||||
* added startup-time selectable network-backend
|
||||
* added location of upload-files to config as array
|
||||
* workaround missing client-bug by assuming we received a close-notify on
|
||||
non-keep-alive requests in SSL request
|
||||
* disabled kerberos5 support by default to fix compilation on RHEL
|
||||
* fixed order of library checks to fix compilation on Solaris 9
|
||||
* fixed open file-descriptors on read-error
|
||||
* fixed crash if /var/tmp is not writable
|
||||
* TODO: export location of upload-files to config as array
|
||||
* TODO: add debugging to mod_webdav
|
||||
|
||||
- 1.4.6 - 2005-10-09
|
||||
|
|
|
@ -441,6 +441,7 @@ typedef struct {
|
|||
buffer *modules_dir;
|
||||
buffer *network_backend;
|
||||
array *modules;
|
||||
array *upload_tempdirs;
|
||||
|
||||
unsigned short max_worker;
|
||||
unsigned short max_fds;
|
||||
|
|
41
src/chunk.c
41
src/chunk.c
|
@ -252,23 +252,54 @@ buffer *chunkqueue_get_append_buffer(chunkqueue *cq) {
|
|||
return c->mem;
|
||||
}
|
||||
|
||||
int chunkqueue_set_tempdirs(chunkqueue *cq, array *tempdirs) {
|
||||
if (!cq) return -1;
|
||||
|
||||
cq->tempdirs = tempdirs;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
chunk *chunkqueue_get_append_tempfile(chunkqueue *cq) {
|
||||
chunk *c;
|
||||
char template[] = "/var/tmp/lighttpd-upload-XXXXXX";
|
||||
buffer *template = buffer_init_string("/var/tmp/lighttpd-upload-XXXXXX");
|
||||
|
||||
c = chunkqueue_get_unused_chunk(cq);
|
||||
|
||||
c->type = FILE_CHUNK;
|
||||
c->offset = 0;
|
||||
if (-1 != (c->file.fd = mkstemp(template))) {
|
||||
/* only trigger the unlink if we created the temp-file successfully */
|
||||
c->file.is_temp = 1;
|
||||
|
||||
if (cq->tempdirs) {
|
||||
size_t i;
|
||||
|
||||
/* we have several tempdirs, only if all of them fail we jump out */
|
||||
|
||||
for (i = 0; i < cq->tempdirs->used; i++) {
|
||||
data_string *ds = (data_string *)cq->tempdirs->data[i];
|
||||
|
||||
buffer_copy_string_buffer(template, ds->value);
|
||||
BUFFER_APPEND_SLASH(template);
|
||||
BUFFER_APPEND_STRING_CONST(template, "lighttpd-upload-XXXXXX");
|
||||
|
||||
if (-1 != (c->file.fd = mkstemp(template->ptr))) {
|
||||
/* only trigger the unlink if we created the temp-file successfully */
|
||||
c->file.is_temp = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (-1 != (c->file.fd = mkstemp(template->ptr))) {
|
||||
/* only trigger the unlink if we created the temp-file successfully */
|
||||
c->file.is_temp = 1;
|
||||
}
|
||||
}
|
||||
|
||||
buffer_copy_string(c->file.name, template);
|
||||
buffer_copy_string_buffer(c->file.name, template);
|
||||
c->file.length = 0;
|
||||
|
||||
chunkqueue_append_chunk(cq, c);
|
||||
|
||||
buffer_free(template);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _CHUNK_H_
|
||||
|
||||
#include "buffer.h"
|
||||
#include "array.h"
|
||||
|
||||
typedef struct chunk {
|
||||
enum { UNUSED_CHUNK, MEM_CHUNK, FILE_CHUNK } type;
|
||||
|
@ -40,10 +41,13 @@ typedef struct {
|
|||
chunk *unused;
|
||||
size_t unused_chunks;
|
||||
|
||||
array *tempdirs;
|
||||
|
||||
off_t bytes_in, bytes_out;
|
||||
} chunkqueue;
|
||||
|
||||
chunkqueue *chunkqueue_init(void);
|
||||
int chunkqueue_set_tempdirs(chunkqueue *c, array *tempdirs);
|
||||
int chunkqueue_append_file(chunkqueue *c, buffer *fn, off_t offset, off_t len);
|
||||
int chunkqueue_append_mem(chunkqueue *c, const char *mem, size_t len);
|
||||
int chunkqueue_append_buffer(chunkqueue *c, buffer *mem);
|
||||
|
|
|
@ -78,6 +78,7 @@ static int config_insert(server *srv) {
|
|||
{ "server.stat-cache-engine", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 41 */
|
||||
{ "server.max-connections", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_SERVER }, /* 42 */
|
||||
{ "server.network-backend", NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION }, /* 43 */
|
||||
{ "server.upload-dirs", NULL, T_CONFIG_ARRAY, T_CONFIG_SCOPE_CONNECTION }, /* 44 */
|
||||
|
||||
{ "server.host", "use server.bind instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
|
||||
{ "server.docroot", "use server.document-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
|
||||
|
@ -114,6 +115,7 @@ static int config_insert(server *srv) {
|
|||
stat_cache_string = buffer_init();
|
||||
cv[41].destination = stat_cache_string;
|
||||
cv[43].destination = srv->srvconf.network_backend;
|
||||
cv[44].destination = srv->srvconf.upload_tempdirs;
|
||||
|
||||
cv[42].destination = &(srv->srvconf.max_conns);
|
||||
cv[12].destination = &(srv->srvconf.max_request_size);
|
||||
|
|
|
@ -594,6 +594,8 @@ 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);
|
||||
|
||||
con->request.headers = array_init();
|
||||
con->response.headers = array_init();
|
||||
con->environment = array_init();
|
||||
|
|
|
@ -165,6 +165,7 @@ static server *server_init(void) {
|
|||
srv->srvconf.modules = array_init();
|
||||
srv->srvconf.modules_dir = buffer_init_string(LIBRARY_DIR);
|
||||
srv->srvconf.network_backend = buffer_init();
|
||||
srv->srvconf.upload_tempdirs = array_init();
|
||||
|
||||
/* use syslog */
|
||||
srv->errorlog_fd = -1;
|
||||
|
|
Loading…
Reference in New Issue