Browse Source

add force_assert for more allocation results

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

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@3072 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/heads/lighttpd-1.4.x
Stefan Bühler 6 years ago
parent
commit
566cf8decb
  1. 1
      NEWS
  2. 6
      src/array.c
  3. 2
      src/chunk.c
  4. 5
      src/connections.c
  5. 1
      src/data_array.c
  6. 1
      src/data_count.c
  7. 1
      src/data_fastcgi.c
  8. 1
      src/data_integer.c
  9. 2
      src/data_string.c
  10. 3
      src/fdevent.c
  11. 1
      src/fdevent_freebsd_kqueue.c
  12. 1
      src/fdevent_linux_sysepoll.c
  13. 4
      src/fdevent_poll.c
  14. 1
      src/fdevent_solaris_devpoll.c
  15. 1
      src/fdevent_solaris_port.c
  16. 4
      src/joblist.c
  17. 3
      src/network.c
  18. 5
      src/plugin.c
  19. 7
      src/stat_cache.c

1
NEWS

@ -7,6 +7,7 @@ NEWS
* [mod_ssi] enhance support for ssi vars (thx fbrosson)
* add handling for lua 5.2 and 5.3 (fixes #2674)
* use libmemcached instead of deprecated libmemcache
* add force_assert for more allocation results
- 1.4.39 - 2016-01-02
* [core] fix memset_s call (fixes #2698)

6
src/array.c

@ -32,13 +32,15 @@ array *array_init_array(array *src) {
a->unique_ndx = src->unique_ndx;
a->data = malloc(sizeof(*src->data) * src->size);
force_assert(NULL != a->data);
for (i = 0; i < src->size; i++) {
if (src->data[i]) a->data[i] = src->data[i]->copy(src->data[i]);
else a->data[i] = NULL;
}
a->sorted = malloc(sizeof(*src->sorted) * src->size);
memcpy(a->sorted, src->sorted, sizeof(*src->sorted) * src->size);
a->sorted = malloc(sizeof(*src->sorted) * src->size);
force_assert(NULL != a->sorted);
memcpy(a->sorted, src->sorted, sizeof(*src->sorted) * src->size);
return a;
}

2
src/chunk.c

@ -24,6 +24,7 @@ chunkqueue *chunkqueue_init(void) {
chunkqueue *cq;
cq = calloc(1, sizeof(*cq));
force_assert(NULL != cq);
cq->first = NULL;
cq->last = NULL;
@ -37,6 +38,7 @@ static chunk *chunk_init(void) {
chunk *c;
c = calloc(1, sizeof(*c));
force_assert(NULL != c);
c->type = MEM_CHUNK;
c->mem = buffer_init();

5
src/connections.c

@ -48,12 +48,14 @@ static connection *connections_get_new_connection(server *srv) {
conns->size = 128;
conns->ptr = NULL;
conns->ptr = malloc(sizeof(*conns->ptr) * conns->size);
force_assert(NULL != conns->ptr);
for (i = 0; i < conns->size; i++) {
conns->ptr[i] = connection_init(srv);
}
} else if (conns->size == conns->used) {
conns->size += 128;
conns->ptr = realloc(conns->ptr, sizeof(*conns->ptr) * conns->size);
force_assert(NULL != conns->ptr);
for (i = conns->used; i < conns->size; i++) {
conns->ptr[i] = connection_init(srv);
@ -646,6 +648,7 @@ connection *connection_init(server *srv) {
UNUSED(srv);
con = calloc(1, sizeof(*con));
force_assert(NULL != con);
con->fd = 0;
con->ndx = -1;
@ -701,8 +704,10 @@ connection *connection_init(server *srv) {
/* init plugin specific connection structures */
con->plugin_ctx = calloc(1, (srv->plugins.used + 1) * sizeof(void *));
force_assert(NULL != con->plugin_ctx);
con->cond_cache = calloc(srv->config_context->used, sizeof(cond_cache_t));
force_assert(NULL != con->cond_cache);
config_setup_connection(srv, con);
return con;

1
src/data_array.c

@ -50,6 +50,7 @@ data_array *data_array_init(void) {
data_array *ds;
ds = calloc(1, sizeof(*ds));
force_assert(NULL != ds);
ds->key = buffer_init();
ds->value = array_init();

1
src/data_count.c

@ -53,6 +53,7 @@ data_count *data_count_init(void) {
data_count *ds;
ds = calloc(1, sizeof(*ds));
force_assert(NULL != ds);
ds->key = buffer_init();
ds->count = 1;

1
src/data_fastcgi.c

@ -52,6 +52,7 @@ data_fastcgi *data_fastcgi_init(void) {
data_fastcgi *ds;
ds = calloc(1, sizeof(*ds));
force_assert(NULL != ds);
ds->key = buffer_init();
ds->host = buffer_init();

1
src/data_integer.c

@ -50,6 +50,7 @@ data_integer *data_integer_init(void) {
data_integer *ds;
ds = calloc(1, sizeof(*ds));
force_assert(NULL != ds);
ds->key = buffer_init();
ds->value = 0;

2
src/data_string.c

@ -97,7 +97,7 @@ data_string *data_string_init(void) {
data_string *ds;
ds = calloc(1, sizeof(*ds));
force_assert(ds);
force_assert(NULL != ds);
ds->key = buffer_init();
ds->value = buffer_init();

3
src/fdevent.c

@ -16,8 +16,10 @@ fdevents *fdevent_init(server *srv, size_t maxfds, fdevent_handler_t type) {
fdevents *ev;
ev = calloc(1, sizeof(*ev));
force_assert(NULL != ev);
ev->srv = srv;
ev->fdarray = calloc(maxfds, sizeof(*ev->fdarray));
force_assert(NULL != ev->fdarray);
ev->maxfds = maxfds;
switch(type) {
@ -107,6 +109,7 @@ static fdnode *fdnode_init(void) {
fdnode *fdn;
fdn = calloc(1, sizeof(*fdn));
force_assert(NULL != fdn);
fdn->fd = -1;
return fdn;
}

1
src/fdevent_freebsd_kqueue.c

@ -199,6 +199,7 @@ int fdevent_freebsd_kqueue_init(fdevents *ev) {
ev->kq_fd = -1;
ev->kq_results = calloc(ev->maxfds, sizeof(*ev->kq_results));
force_assert(NULL != ev->kq_results);
/* check that kqueue works */

1
src/fdevent_linux_sysepoll.c

@ -143,6 +143,7 @@ int fdevent_linux_sysepoll_init(fdevents *ev) {
fd_close_on_exec(ev->epoll_fd);
ev->epoll_events = malloc(ev->maxfds * sizeof(*ev->epoll_events));
force_assert(NULL != ev->epoll_events);
return 0;
}

4
src/fdevent_poll.c

@ -44,9 +44,11 @@ static int fdevent_poll_event_del(fdevents *ev, int fde_ndx, int fd) {
if (ev->unused.size == 0) {
ev->unused.size = 16;
ev->unused.ptr = malloc(sizeof(*(ev->unused.ptr)) * ev->unused.size);
force_assert(NULL != ev->unused.ptr);
} else if (ev->unused.size == ev->unused.used) {
ev->unused.size += 16;
ev->unused.ptr = realloc(ev->unused.ptr, sizeof(*(ev->unused.ptr)) * ev->unused.size);
force_assert(NULL != ev->unused.ptr);
}
ev->unused.ptr[ev->unused.used++] = k;
@ -102,9 +104,11 @@ static int fdevent_poll_event_set(fdevents *ev, int fde_ndx, int fd, int events)
if (ev->size == 0) {
ev->size = 16;
ev->pollfds = malloc(sizeof(*ev->pollfds) * ev->size);
force_assert(NULL != ev->pollfds);
} else if (ev->size == ev->used) {
ev->size += 16;
ev->pollfds = realloc(ev->pollfds, sizeof(*ev->pollfds) * ev->size);
force_assert(NULL != ev->pollfds);
}
ev->pollfds[ev->used].fd = fd;

1
src/fdevent_solaris_devpoll.c

@ -141,6 +141,7 @@ int fdevent_solaris_devpoll_init(fdevents *ev) {
SET(event_get_revent);
ev->devpollfds = malloc(sizeof(*ev->devpollfds) * ev->maxfds);
force_assert(NULL != ev->devpollfds);
if ((ev->devpoll_fd = open("/dev/poll", O_RDWR)) < 0) {
log_error_write(ev->srv, __FILE__, __LINE__, "SSS",

1
src/fdevent_solaris_port.c

@ -156,6 +156,7 @@ int fdevent_solaris_port_init(fdevents *ev) {
}
ev->port_events = malloc(ev->maxfds * sizeof(*ev->port_events));
force_assert(NULL != ev->port_events);
return 0;
}

4
src/joblist.c

@ -11,9 +11,11 @@ int joblist_append(server *srv, connection *con) {
if (srv->joblist->size == 0) {
srv->joblist->size = 16;
srv->joblist->ptr = malloc(sizeof(*srv->joblist->ptr) * srv->joblist->size);
force_assert(NULL != srv->joblist->ptr);
} 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);
force_assert(NULL != srv->joblist->ptr);
}
srv->joblist->ptr[srv->joblist->used++] = con;
@ -46,9 +48,11 @@ 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);
force_assert(NULL != srv->fdwaitqueue->ptr);
} 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);
force_assert(NULL != srv->fdwaitqueue->ptr);
}
srv->fdwaitqueue->ptr[srv->fdwaitqueue->used++] = con;

3
src/network.c

@ -183,6 +183,7 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
#endif
srv_socket = calloc(1, sizeof(*srv_socket));
force_assert(NULL != srv_socket);
srv_socket->fd = -1;
srv_socket->fde_ndx = -1;
@ -460,9 +461,11 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
srv->srv_sockets.size = 4;
srv->srv_sockets.used = 0;
srv->srv_sockets.ptr = malloc(srv->srv_sockets.size * sizeof(server_socket*));
force_assert(NULL != srv->srv_sockets.ptr);
} else if (srv->srv_sockets.used == srv->srv_sockets.size) {
srv->srv_sockets.size += 4;
srv->srv_sockets.ptr = realloc(srv->srv_sockets.ptr, srv->srv_sockets.size * sizeof(server_socket*));
force_assert(NULL != srv->srv_sockets.ptr);
}
srv->srv_sockets.ptr[srv->srv_sockets.used++] = srv_socket;

5
src/plugin.c

@ -53,6 +53,7 @@ static plugin *plugin_init(void) {
plugin *p;
p = calloc(1, sizeof(*p));
force_assert(NULL != p);
return p;
}
@ -85,10 +86,12 @@ static int plugins_register(server *srv, plugin *p) {
if (0 == srv->plugins.size) {
srv->plugins.size = 4;
srv->plugins.ptr = malloc(srv->plugins.size * sizeof(*ps));
force_assert(NULL != srv->plugins.ptr);
srv->plugins.used = 0;
} else if (srv->plugins.used == srv->plugins.size) {
srv->plugins.size += 4;
srv->plugins.ptr = realloc(srv->plugins.ptr, srv->plugins.size * sizeof(*ps));
force_assert(NULL != srv->plugins.ptr);
}
ps = srv->plugins.ptr;
@ -423,6 +426,7 @@ handler_t plugins_call_init(server *srv) {
/* fill slots */
srv->plugin_slots = calloc(PLUGIN_FUNC_SIZEOF, sizeof(ps));
force_assert(NULL != srv->plugin_slots);
for (i = 0; i < srv->plugins.used; i++) {
size_t j;
@ -435,6 +439,7 @@ handler_t plugins_call_init(server *srv) {
plugin **slot = ((plugin ***)(srv->plugin_slots))[x]; \
if (!slot) { \
slot = calloc(srv->plugins.used, sizeof(*slot));\
force_assert(NULL != slot); \
((plugin ***)(srv->plugin_slots))[x] = slot; \
} \
for (j = 0; j < srv->plugins.used; j++) { \

7
src/stat_cache.c

@ -108,6 +108,7 @@ stat_cache *stat_cache_init(void) {
stat_cache *sc = NULL;
sc = calloc(1, sizeof(*sc));
force_assert(NULL != sc);
sc->dir_name = buffer_init();
sc->hash_key = buffer_init();
@ -127,6 +128,7 @@ static stat_cache_entry * stat_cache_entry_init(void) {
stat_cache_entry *sce = NULL;
sce = calloc(1, sizeof(*sce));
force_assert(NULL != sce);
sce->name = buffer_init();
sce->etag = buffer_init();
@ -151,6 +153,7 @@ static fam_dir_entry * fam_dir_entry_init(void) {
fam_dir_entry *fam_dir = NULL;
fam_dir = calloc(1, sizeof(*fam_dir));
force_assert(NULL != fam_dir);
fam_dir->name = buffer_init();
@ -518,9 +521,11 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_
ctrl.size = 16;
ctrl.used = 0;
ctrl.ptr = malloc(ctrl.size * sizeof(*ctrl.ptr));
force_assert(NULL != ctrl.ptr);
} else if (ctrl.size == ctrl.used) {
ctrl.size += 16;
ctrl.ptr = realloc(ctrl.ptr, ctrl.size * sizeof(*ctrl.ptr));
force_assert(NULL != ctrl.ptr);
}
ctrl.ptr[ctrl.used++] = file_ndx;
@ -640,6 +645,7 @@ handler_t stat_cache_get_entry(server *srv, connection *con, buffer *name, stat_
fam_dir->version = 1;
fam_dir->req = calloc(1, sizeof(FAMRequest));
force_assert(NULL != fam_dir);
if (0 != FAMMonitorDirectory(&sc->fam, fam_dir->name->ptr,
fam_dir->req, fam_dir)) {
@ -719,6 +725,7 @@ int stat_cache_trigger_cleanup(server *srv) {
if (!sc->files) return 0;
keys = calloc(1, sizeof(int) * sc->files->size);
force_assert(NULL != keys);
stat_cache_tag_old_entries(srv, sc->files, keys, &max_ndx);

Loading…
Cancel
Save