[pjsip] PJSUA allocates call id

Benny Prijono bennylp at pjsip.org
Tue Feb 26 05:32:47 EST 2008


On 2/26/08, Truong Thanh Quang <quangtt at softend.vn> wrote:
>
>  Hi all,
>
>  I think this is a bug in PJSUA when allocating call_id
>
>  r1820, pjsua_call.c:218
>  static pjsua_call_id alloc_call_id(void)
>  {
>      pjsua_call_id cid;
>                          #if 1
>
>
>     /* New algorithm: round-robin */
>      if (pjsua_var.next_call_id >= (int)pjsua_var.ua_cfg.max_calls ||
>      pjsua_var.next_call_id < 0)
>      {
>      cid = 0;
>      }
>
>      for (cid=pjsua_var.next_call_id;
>       cid<(int)pjsua_var.ua_cfg.max_calls;
>       ++cid)
>      {
>      if (pjsua_var.calls[cid].inv == NULL) {
>          ++pjsua_var.next_call_id;
>          return cid;
>      }
>      }
>
>      for (cid=0; cid < pjsua_var.next_call_id; ++cid) {
>      if (pjsua_var.calls[cid].inv == NULL) {
>          ++pjsua_var.next_call_id;
>          return cid;
>      }
>      }
>
>  #else
>
>  when pjsua_var.next_call_id > (int)pjsua_var.ua_cfg.max_calls the next for
> loop will never be executed and from now on, allcating call_id will be the
> same with old algorithm.
>  I think line 227 should be: pjsua_var.next_call_id = ; (instead of cid =
> 0;)


You're right, and that was a silly bug! Thanks for spotting it, and
it's been fixed in http://trac.pjsip.org/repos/ticket/455#comment:3

cheers,
 -benny




More information about the pjsip mailing list