diff --git a/daemon/call.c b/daemon/call.c index 6c5a34682..8de1cf73b 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -4040,7 +4040,7 @@ static struct call *call_create(const str *callid) { } /* returns call with master_lock held in W */ -struct call *call_get_or_create(const str *callid, bool foreign, bool exclusive) { +struct call *call_get_or_create(const str *callid, bool exclusive) { struct call *c; restart: @@ -4060,10 +4060,6 @@ restart: g_hash_table_insert(rtpe_callhash, &c->callid, obj_get(c)); RTPE_GAUGE_INC(total_sessions); - bf_set_clear(&c->call_flags, CALL_FLAG_FOREIGN, foreign); - - statistics_update_foreignown_inc(c); - rwlock_lock_w(&c->master_lock); rwlock_unlock_w(&rtpe_callhash_lock); @@ -4142,7 +4138,7 @@ struct call *call_get(const str *callid) { /* returns call with master_lock held in W, or possibly NULL iff opmode == OP_ANSWER */ struct call *call_get_opmode(const str *callid, enum call_opmode opmode) { if (opmode == OP_OFFER) - return call_get_or_create(callid, false, false); + return call_get_or_create(callid, false); return call_get(callid); } diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 12a003315..23e96dcc2 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -2019,7 +2019,7 @@ static const char *call_offer_answer_ng(struct ng_buffer *ngbuf, bencode_item_t goto out; } - call = call_get_or_create(&flags.call_id, false, false); + call = call_get_or_create(&flags.call_id, false); } errstr = "Unknown call-id"; @@ -3384,7 +3384,7 @@ const char *call_publish_ng(struct ng_buffer *ngbuf, bencode_item_t *input, benc if (sdp_streams(&parsed, &streams, &flags)) return "Incomplete SDP specification"; - call = call_get_or_create(&flags.call_id, false, false); + call = call_get_or_create(&flags.call_id, false); if (trickle_ice_update(ngbuf, call, &flags, &streams)) return NULL; diff --git a/daemon/janus.c b/daemon/janus.c index 1ea20ff7b..df28024d6 100644 --- a/daemon/janus.c +++ b/daemon/janus.c @@ -208,7 +208,7 @@ static const char *janus_videoroom_create(struct janus_session *session, struct continue; room->call_id.s = janus_call_id(room_id); room->call_id.len = strlen(room->call_id.s); - struct call *call = call_get_or_create(&room->call_id, false, true); + struct call *call = call_get_or_create(&room->call_id, true); if (!call) { ilog(LOG_WARN, "Call with reserved Janus ID '" STR_FORMAT "' already exists", STR_FMT(&room->call_id)); diff --git a/daemon/redis.c b/daemon/redis.c index e59dd6524..953fb6344 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -1971,7 +1971,7 @@ static void json_restore_call(struct redis *r, const str *callid, bool foreign) goto err1; - c = call_get_or_create(callid, foreign, false); + c = call_get_or_create(callid, false); err = "failed to create call struct"; if (!c) goto err1; @@ -2075,6 +2075,11 @@ static void json_restore_call(struct redis *r, const str *callid, bool foreign) recording_start(c, s.s, NULL); } + // force-clear foreign flag (could have been set through call_flags), then + // set it to what we want, updating the statistics if needed + CALL_CLEAR(c, FOREIGN); + call_make_own_foreign(c, foreign); + err = NULL; err8: diff --git a/include/call.h b/include/call.h index a2adfb83a..02b80326c 100644 --- a/include/call.h +++ b/include/call.h @@ -746,7 +746,7 @@ void call_subscription_free(void *); void call_subscriptions_clear(GQueue *q); -struct call *call_get_or_create(const str *callid, bool foreign, bool exclusive); +struct call *call_get_or_create(const str *callid, bool exclusive); struct call *call_get_opmode(const str *callid, enum call_opmode opmode); void call_make_own_foreign(struct call *c, bool foreign); int call_get_mono_dialogue(struct call_monologue *monologues[2], struct call *call, diff --git a/t/test-stats.c b/t/test-stats.c index 7dc80cac8..4f19c538b 100644 --- a/t/test-stats.c +++ b/t/test-stats.c @@ -4304,9 +4304,9 @@ int main(void) { const str callid1 = STR_CONST_INIT("test1"); const str callid2 = STR_CONST_INIT("test2"); - struct call *call1 = call_get_or_create(&callid1, false, true); + struct call *call1 = call_get_or_create(&callid1, true); struct call_monologue *ml1 = call_get_or_create_monologue(call1, &callid1); - struct call *call2 = call_get_or_create(&callid2, false, true); + struct call *call2 = call_get_or_create(&callid2, true); struct call_monologue *ml2 = call_get_or_create_monologue(call2, &callid2); call1->created = ml1->started = (struct timeval) {157,0}; call2->created = ml2->started = (struct timeval) {57,0};