Skip to content

Commit

Permalink
qualify: fix OPTIONS refcounting
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilianfridrich committed Dec 15, 2023
1 parent 6a93b0c commit 3dd4c0f
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions modules/qualify/qualify.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static void options_resp_handler(int err, const struct sip_msg *msg, void *arg)
struct qualle *qualle = arg;

if (err) {
warning("qualify: OPTIONS reply error (%m)\n", err);
info("qualify: OPTIONS reply error (%m)\n", err);
mem_deref(qualle);
return;
}
Expand Down Expand Up @@ -226,33 +226,34 @@ static bool qualle_get_applyh(struct le *le, void *arg)
}


static void call_stop_qualify(struct call *call, bool closed)
static struct qualle *call_get_qualle(const struct call *call)
{
struct qualle *qualle;

if (!call)
return;
return NULL;

struct le *le = hash_lookup(q.qual_map,
hash_fast_str(call_id(call)),
qualle_get_applyh, NULL);

if (!le || !le->data)
return;
return le ? le->data : NULL;
}

qualle = le->data;

if (closed)
qualle->call = NULL;
static void qualle_stop_tmrs(struct qualle *qualle)
{
if (!qualle)
return;

mem_deref(qualle);
tmr_cancel(&qualle->to_tmr);
tmr_cancel(&qualle->int_tmr);
}


static void ua_event_handler(struct ua *ua, enum ua_event ev,
struct call *call, const char *prm, void *arg)
{
struct account *acc = ua_account(ua);
struct qualle *qualle;
(void) call;
(void) prm;
(void) arg;
Expand All @@ -261,15 +262,24 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev,
case UA_EVENT_CALL_INCOMING:
(void)call_start_qualify(call, acc, NULL);
break;

case UA_EVENT_CALL_ESTABLISHED:
case UA_EVENT_CALL_ANSWERED:
if (call_is_outgoing(call))
break;

call_stop_qualify(call, false);
qualle = call_get_qualle(call);
qualle_stop_tmrs(qualle);
break;

case UA_EVENT_CALL_CLOSED:
call_stop_qualify(call, true);
qualle = call_get_qualle(call);
qualle_stop_tmrs(qualle);

if (qualle) {
qualle->call = NULL;
mem_deref(qualle);
}

break;
default:
break;
Expand Down

0 comments on commit 3dd4c0f

Please sign in to comment.