diff options
author | Arno Töll <arno@debian.org> | 2012-11-21 23:03:34 +0100 |
---|---|---|
committer | Arno Töll <arno@debian.org> | 2012-11-21 23:03:34 +0100 |
commit | eb45c46b906e492f063f1469486190e93ff340ff (patch) | |
tree | 85d615969fa7bf8056a05b59006f77bc63e85892 /src/joblist.c | |
parent | 6426b37107707a1d95ffd03f68620cbda8bdb942 (diff) | |
download | lighttpd-eb45c46b906e492f063f1469486190e93ff340ff.tar.gz |
Imported Upstream version 1.4.10upstream/1.4.10
Diffstat (limited to 'src/joblist.c')
-rw-r--r-- | src/joblist.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/joblist.c b/src/joblist.c new file mode 100644 index 0000000..dcab955 --- /dev/null +++ b/src/joblist.c @@ -0,0 +1,63 @@ +#include <stdlib.h> +#include <string.h> + +#include "base.h" +#include "joblist.h" +#include "log.h" + +int joblist_append(server *srv, connection *con) { + if (con->in_joblist) return 0; + + if (srv->joblist->size == 0) { + srv->joblist->size = 16; + srv->joblist->ptr = malloc(sizeof(*srv->joblist->ptr) * srv->joblist->size); + } else if (srv->joblist->used == srv->joblist->size) { + srv->joblist->size += 16; + srv->joblist->ptr = realloc(srv->joblist->ptr, sizeof(*srv->joblist->ptr) * srv->joblist->size); + } + + srv->joblist->ptr[srv->joblist->used++] = con; + + return 0; +} + +void joblist_free(server *srv, connections *joblist) { + UNUSED(srv); + + free(joblist->ptr); + free(joblist); +} + +connection *fdwaitqueue_unshift(server *srv, connections *fdwaitqueue) { + connection *con; + UNUSED(srv); + + + if (fdwaitqueue->used == 0) return NULL; + + con = fdwaitqueue->ptr[0]; + + memmove(fdwaitqueue->ptr, &(fdwaitqueue->ptr[1]), --fdwaitqueue->used * sizeof(*(fdwaitqueue->ptr))); + + return con; +} + +int fdwaitqueue_append(server *srv, connection *con) { + if (srv->fdwaitqueue->size == 0) { + srv->fdwaitqueue->size = 16; + srv->fdwaitqueue->ptr = malloc(sizeof(*(srv->fdwaitqueue->ptr)) * srv->fdwaitqueue->size); + } else if (srv->fdwaitqueue->used == srv->fdwaitqueue->size) { + srv->fdwaitqueue->size += 16; + srv->fdwaitqueue->ptr = realloc(srv->fdwaitqueue->ptr, sizeof(*(srv->fdwaitqueue->ptr)) * srv->fdwaitqueue->size); + } + + srv->fdwaitqueue->ptr[srv->fdwaitqueue->used++] = con; + + return 0; +} + +void fdwaitqueue_free(server *srv, connections *fdwaitqueue) { + UNUSED(srv); + free(fdwaitqueue->ptr); + free(fdwaitqueue); +} |