Skip to content

Commit 147072a

Browse files
committed
dialog: ensure legs are atomically added to the dialog
1 parent cfbfd3f commit 147072a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/dialog/dlg_handlers.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,11 +1424,18 @@ static void dlg_onreq_out(struct cell* t, int type, struct tmcb_params *ps)
14241424
dlg_lock_dlg(dlg);
14251425

14261426
callee_leg = d_tmb.get_branch_index() + 1;
1427+
LM_DBG("pushing new leg %d/%d\n",
1428+
callee_leg, dlg->legs_no[DLG_LEGS_USED]);
14271429
if (ensure_leg_array(callee_leg + 1, dlg) != 0)
14281430
goto out_free;
14291431

14301432
/* store the caller SDP into each callee leg, useful for Re-INVITE pings */
14311433
leg = &dlg->legs[callee_leg];
1434+
if (callee_leg >= dlg->legs_no[DLG_LEGS_USED])
1435+
dlg->legs_no[DLG_LEGS_USED] = callee_leg + 1;
1436+
else
1437+
LM_BUG("wrongfully increasing callee_leg %d/%d\n",
1438+
callee_leg, dlg->legs_no[DLG_LEGS_USED]);
14321439

14331440
dlg_unlock_dlg(dlg);
14341441

@@ -1453,8 +1460,6 @@ static void dlg_onreq_out(struct cell* t, int type, struct tmcb_params *ps)
14531460
}
14541461
}
14551462

1456-
dlg->legs_no[DLG_LEGS_USED]++;
1457-
14581463
out_free:
14591464
dlg_unlock_dlg(dlg);
14601465
free_sip_msg(msg);

0 commit comments

Comments
 (0)