Re-registration problem with expires less than PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I found a problem in re-registration process while making some tests.
I send REGISTER request and receive 200 OK answer with "expires=3" param.
BTW PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH is set to default 5 seconds.
In log i see:
12:03:01.619    pjsua_acc.c  ...."ABCDE" <sip:alexey2@xxxxxxx>: registration success, status=200 (OK), will re-register in 3 seconds
In cbRegState I call pjsua_acc_get_info to get the info about account, it has the following params:
accInfo.has_registration = 1
accinfo.expires = -2

Reregistration never happens.

It looks like the problem is in schedule_registration(...) func (sip_reg.c).
======
        delay.sec = expiration - regc->delay_before_refresh;
======
This line has a bug. We calculate (pj_int32_t - pj_uint32_t), the 1st argument is promoted to unsigned. In my case we have (unsigned)3-(unsigned)5, the result is huge unsigned int, reregistration will be made in 136 years!
That line can be corrected the next way:
======
        delay.sec = expiration - (pj_int32_t)regc->delay_before_refresh;
======

As for me a following check doesn't match 10.2.4 RFC 3261.
======
        if (delay.sec < DELAY_BEFORE_REFRESH) 
            delay.sec = DELAY_BEFORE_REFRESH;
======
I think comparing to DELAY_BEFORE_REFRESH is not a good idea. Using DELAY_BEFORE_REFRESH for regular reregistration looks nice, but not here.
I think in case of the "expires" is less then DELAY_BEFORE_REFRESH, we should obey the param.
I suggest to modify it the following way:
======
        if (delay.sec < 0) 
            delay.sec = expiration-1;
======
We should use "expiration-1" to be in time, "-1" has the same role as PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH in regular reregistration.

The patch for changes:
========================================
819c819
<         delay.sec = expiration - regc->delay_before_refresh;
---
>         delay.sec = expiration - (pj_int32_t)regc->delay_before_refresh;
825,826c825,826
<         if (delay.sec < DELAY_BEFORE_REFRESH) 
<             delay.sec = DELAY_BEFORE_REFRESH;
---
>         if (delay.sec < 0) 
>             delay.sec = expiration-1;
========================================

PJSIP version is 2.5. It looks like the bug is present in 2.6 also.

---
Alexey Ermoshin

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux