diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-11-28 17:21:25 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-11-28 17:21:25 +0200 |
commit | 3764826c5c86a54d3562d0ae4dad7c746fc1b7fc (patch) | |
tree | 6d9d8f6a9b17359141d850393510d45ce781a846 | |
parent | 46a93f1575cff6a1afa1d793a33f87d3c655ac83 (diff) | |
download | tallyman-3764826c5c86a54d3562d0ae4dad7c746fc1b7fc.tar.gz tallyman-3764826c5c86a54d3562d0ae4dad7c746fc1b7fc.tar.bz2 |
Bugfixes
* src/config.c (cb_service): Fix improper datatype of listen_address.
* src/servdb.c: Fix deadlock:
(servdb_update): Call table_validity_clear after unlocking
the mutex.
(invalidator_thread): Likewise.
-rw-r--r-- | src/config.c | 3 | ||||
-rw-r--r-- | src/servdb.c | 7 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/config.c b/src/config.c index 78689d8..2dc4bd5 100644 --- a/src/config.c +++ b/src/config.c @@ -177,7 +177,8 @@ cb_service(enum grecs_callback_command cmd, grecs_node_t *node, static struct grecs_keyword tallymand_kw[] = { { "listen", "socket", "Listen on this address", - grecs_type_sockaddr, GRECS_DFLT, &listen_address, }, + grecs_type_string /* FIXME: consider grecs_type_sockaddr */, + GRECS_DFLT, &listen_address, }, { "pidfile", "file", "Store PID in that file", grecs_type_string, GRECS_DFLT, &pidfile }, { "user", "name|+uid", "Run as this user", diff --git a/src/servdb.c b/src/servdb.c index b4ae6d6..3a81bac 100644 --- a/src/servdb.c +++ b/src/servdb.c @@ -269,9 +269,9 @@ servdb_update(struct json_value *obj) ? instance_state_running : instance_state_stopped; } - table_validity_clear(); instance_unlock(inst); pthread_mutex_unlock(&srv->mutex); + table_validity_clear(); return 0; } @@ -538,6 +538,7 @@ invalidator_thread(void *p) struct instance *inst; while (1) { time_t now = time(NULL); + int invalidate = 0; for (i = 0; i < service_count; i++) { pthread_mutex_lock(&service[i].mutex); for (inst = service[i].head; inst; inst = inst->next) { @@ -546,10 +547,12 @@ invalidator_thread(void *p) && now - inst->timestamp > ttl_instance_state) inst->state = instance_state_expired; instance_unlock(inst); - table_validity_clear(); + invalidate = 1; } pthread_mutex_unlock(&service[i].mutex); } + if (invalidate) + table_validity_clear(); sleep(ttl_instance_state); } return NULL; |