MT#57977 fix save/restore of "foreign" call flag

With the "foreign" flag now stored in call_flags, restoring a call from
Redis restores this flag as well, overwriting the desired flag as we had
set it through call_get_or_create().

Reverse the flag setting by taking it out of call_get_or_create() (where
it's always false anyway, except when coming from Redis) and setting it
explicitly with call_make_own_foreign() after restorting call and its
flags.

Change-Id: Ib68be2aeedfa988b7555e426fa337657e1062245
dzenichev/fictitious
Richard Fuchs 2 years ago
parent bb9fbbbcad
commit dbae76c3b6

@ -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);
}

@ -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;

@ -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));

@ -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:

@ -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,

@ -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};

Loading…
Cancel
Save