Changeset 275


Ignore:
Timestamp:
Mar 3, 2006 10:23:35 AM (18 years ago)
Author:
bennylp
Message:

Terminate pending SUBSCRIBE if application sends another one (e.g. to unsubscribe)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip-simple/evsub.c

    r268 r275  
    212212    pj_timer_entry        timer;        /**< Internal timer.                */ 
    213213    int                   pending_tsx;  /**< Number of pending transactions.*/ 
     214    pjsip_transaction    *pending_sub;  /**< Pending UAC SUBSCRIBE tsx.     */ 
    214215 
    215216    void                 *mod_data[PJSIP_MAX_MODULE];   /**< Module data.   */ 
     
    12981299    sub->pending_tsx++; 
    12991300 
     1301    /* Special case for outgoing/UAC SUBSCRIBE/REFER transaction.  
     1302     * We can only have one pending UAC SUBSCRIBE/REFER, so if another  
     1303     * transaction is started while previous one still alive, terminate 
     1304     * the older one. 
     1305     * 
     1306     * Sample scenario: 
     1307     *  - subscribe sent to destination that doesn't exist, transaction 
     1308     *    is still retransmitting request, then unsubscribe is sent. 
     1309     */ 
     1310    if (tsx->role == PJSIP_ROLE_UAC && 
     1311        tsx->state == PJSIP_TSX_STATE_CALLING && 
     1312        pjsip_method_cmp(&tsx->method, &sub->method) == 0)  
     1313    { 
     1314 
     1315        if (sub->pending_sub &&  
     1316            sub->pending_sub->state < PJSIP_TSX_STATE_COMPLETED)  
     1317        { 
     1318            PJ_LOG(4,(sub->obj_name,  
     1319                      "Cancelling pending %.*s request", 
     1320                      (int)sub->method.name.slen, sub->method.name.ptr)); 
     1321 
     1322            /* By convention, we use 490 (Request Updated) status code. 
     1323             * When transaction handler (below) see this status code, it 
     1324             * will ignore the transaction. 
     1325             */ 
     1326            pjsip_tsx_terminate(sub->pending_sub, PJSIP_SC_REQUEST_UPDATED); 
     1327        } 
     1328 
     1329        sub->pending_sub = tsx; 
     1330 
     1331    } else if (tsx == sub->pending_sub && 
     1332               tsx->state >= PJSIP_TSX_STATE_COMPLETED) 
     1333    { 
     1334        sub->pending_sub = NULL; 
     1335    } 
     1336 
    13001337    return sub; 
    13011338} 
     
    15051542            if (sub->state == PJSIP_EVSUB_STATE_TERMINATED) { 
    15061543                /* Ignore, has been handled before */ 
     1544                return; 
     1545            } 
     1546 
     1547            /* Ignore 490 (Request Updated) status.  
     1548             * This happens when application sends SUBSCRIBE/REFER while  
     1549             * another one is still in progress. 
     1550             */ 
     1551            if (tsx->status_code == PJSIP_SC_REQUEST_UPDATED) { 
    15071552                return; 
    15081553            } 
Note: See TracChangeset for help on using the changeset viewer.