Browse Source

analoguous to the last race, call_destroy() must not assume that it's getting the last reference to the call

git.mgm/mediaproxy-ng/2.1
Richard Fuchs 14 years ago
parent
commit
b7a68659b1
2 changed files with 22 additions and 3 deletions
  1. +19
    -3
      daemon/call.c
  2. +3
    -0
      daemon/call.h

+ 19
- 3
daemon/call.c View File

@ -1316,16 +1316,30 @@ static void call_destroy(struct call *c) {
struct callmaster *m = c->callmaster; struct callmaster *m = c->callmaster;
struct callstream *s; struct callstream *s;
restart:
rwlock_lock_w(&m->hashlock); rwlock_lock_w(&m->hashlock);
g_hash_table_remove(m->callhash, c->callid); /* steal this ref */
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);
}
rwlock_unlock_w(&m->hashlock); rwlock_unlock_w(&m->hashlock);
if (redis_delete) if (redis_delete)
redis_delete(c, m->conf.redis); 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); mylog(LOG_INFO, LOG_PREFIX_C "Final packet stats:", c->callid);
while (c->callstreams->head) { while (c->callstreams->head) {
s = g_queue_pop_head(c->callstreams); s = g_queue_pop_head(c->callstreams);
mutex_unlock(&c->lock);
mutex_lock(&s->lock);
mylog(LOG_INFO, LOG_PREFIX_C mylog(LOG_INFO, LOG_PREFIX_C
"--- " "--- "
"side A: " "side A: "
@ -1344,10 +1358,12 @@ static void call_destroy(struct call *c) {
s->peers[1].rtps[1].localport, s->peers[1].rtps[1].stats.packets, s->peers[1].rtps[1].localport, s->peers[1].rtps[1].stats.packets,
s->peers[1].rtps[1].stats.bytes, s->peers[1].rtps[1].stats.errors); s->peers[1].rtps[1].stats.bytes, s->peers[1].rtps[1].stats.errors);
kill_callstream(s); kill_callstream(s);
mutex_unlock(&s->lock);
obj_put(s); obj_put(s);
mutex_lock(&c->lock);
} }
obj_put(c);
out:
mutex_unlock(&c->lock);
} }


+ 3
- 0
daemon/call.h View File

@ -93,6 +93,9 @@ struct call {
time_t created; time_t created;
GHashTable *infohash; GHashTable *infohash;
time_t lookup_done; time_t lookup_done;
int linked:1;
int shutdown:1;
}; };
struct callmaster_config { struct callmaster_config {


Loading…
Cancel
Save