From 94f2f320a641f4cfdf0e88d058df8ad23bec0f91 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Sun, 5 Aug 2012 15:20:34 +0000 Subject: [PATCH] actually the call struct needs neither linked flag nor shutdown flag due to the sequence of events and locking --- daemon/call.c | 20 +++++++------------- daemon/call.h | 3 --- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 413868bad..e64cf501e 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1327,26 +1327,21 @@ static void kill_callstream(struct callstream *s) { static void call_destroy(struct call *c) { struct callmaster *m = c->callmaster; struct callstream *s; + int ret; -restart: rwlock_lock_w(&m->hashlock); - if (c->linked) { - if (!g_hash_table_remove(m->callhash, c->callid)) { - rwlock_unlock_w(&m->hashlock); - goto restart; - } - c->linked = 0; - obj_put(c); - } + ret = g_hash_table_remove(m->callhash, c->callid); rwlock_unlock_w(&m->hashlock); + if (!ret) + return; + + obj_put(c); + if (redis_delete) redis_delete(c, m->conf.redis); mutex_lock(&c->lock); - if (c->shutdown) - goto out; - c->shutdown = 1; mylog(LOG_INFO, LOG_PREFIX_C "Final packet stats:", c->callid); while (c->callstreams->head) { s = g_queue_pop_head(c->callstreams); @@ -1374,7 +1369,6 @@ restart: obj_put(s); mutex_lock(&c->lock); } -out: mutex_unlock(&c->lock); } diff --git a/daemon/call.h b/daemon/call.h index b03713402..25ad1aa9b 100644 --- a/daemon/call.h +++ b/daemon/call.h @@ -93,9 +93,6 @@ struct call { time_t created; GHashTable *infohash; time_t lookup_done; - - int linked:1; - int shutdown:1; }; struct callmaster_config {