Changeset 841


Ignore:
Timestamp:
Dec 1, 2006 8:50:01 PM (14 years ago)
Author:
bennylp
Message:

Fixed ticket #34: unable to send REGISTER in the registration callback

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c

    r799 r841  
    4747    pjsip_endpoint              *endpt; 
    4848    pj_bool_t                    _delete_flag; 
    49     int                          pending_tsx; 
     49    pj_bool_t                    has_tsx; 
     50    pj_int32_t                   busy; 
    5051 
    5152    void                        *token; 
     
    120121    PJ_ASSERT_RETURN(regc, PJ_EINVAL); 
    121122 
    122     if (regc->pending_tsx) { 
     123    if (regc->has_tsx || regc->busy) { 
    123124        regc->_delete_flag = 1; 
    124125        regc->cb = NULL; 
     
    138139    info->server_uri = regc->str_srv_url; 
    139140    info->client_uri = regc->from_uri; 
    140     info->is_busy = (regc->pending_tsx != 0); 
     141    info->is_busy = (regc->busy || regc->has_tsx); 
    141142    info->auto_reg = regc->auto_reg; 
    142143    info->interval = regc->expires; 
    143144     
    144     if (regc->pending_tsx) 
     145    if (regc->has_tsx) 
    145146        info->next_reg = 0; 
    146147    else if (regc->auto_reg == 0) 
     
    522523     
    523524    /* Decrement pending transaction counter. */ 
    524     pj_assert(regc->pending_tsx > 0); 
    525     --regc->pending_tsx; 
     525    pj_assert(regc->has_tsx); 
     526    regc->has_tsx = PJ_FALSE; 
    526527 
    527528    /* If registration data has been deleted by user then remove registration  
     
    615616        } 
    616617 
    617         /* Increment pending_tsx temporarily to prevent regc from 
     618        /* Increment busy flag temporarily to prevent regc from 
    618619         * being destroyed. 
    619620         */ 
    620         ++regc->pending_tsx; 
     621        ++regc->busy; 
    621622 
    622623        /* Call callback. */ 
     
    628629                      contact_cnt, contact); 
    629630 
    630         /* Decrement pending_tsx */ 
    631         --regc->pending_tsx; 
     631        /* Decrement busy flag */ 
     632        --regc->busy; 
    632633    } 
    633634 
    634635    /* Delete the record if user destroy regc during the callback. */ 
    635     if (regc->_delete_flag && regc->pending_tsx==0) { 
     636    if (regc->_delete_flag && regc->busy==0) { 
    636637        pjsip_regc_destroy(regc); 
    637638    } 
     
    645646 
    646647    /* Make sure we don't have pending transaction. */ 
    647     if (regc->pending_tsx) { 
     648    if (regc->has_tsx) { 
    648649        PJ_LOG(4,(THIS_FILE, "Unable to send request, regc has another " 
    649650                             "transaction pending")); 
     
    663664     * may be called even before send_request() returns! 
    664665     */ 
    665     regc->pending_tsx += 2; 
     666    regc->has_tsx = PJ_TRUE; 
     667    ++regc->busy; 
    666668    status = pjsip_endpt_send_request(regc->endpt, tdata, -1, regc, &tsx_callback); 
    667669    if (status!=PJ_SUCCESS) { 
    668670        PJ_LOG(4,(THIS_FILE, "Error sending request, status=%d", status)); 
    669671    } 
    670     --regc->pending_tsx; 
     672    --regc->busy; 
    671673 
    672674    /* Delete the record if user destroy regc during the callback. */ 
    673     if (regc->_delete_flag && regc->pending_tsx==0) { 
     675    if (regc->_delete_flag && regc->busy==0) { 
    674676        pjsip_regc_destroy(regc); 
    675677    } 
Note: See TracChangeset for help on using the changeset viewer.