Changeset 6142
- Timestamp:
- Jan 29, 2020 4:05:51 AM (5 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip-ua/sip_regc.h
r6035 r6142 210 210 pj_uint32_t expires); 211 211 212 213 /** 214 * Increment busy counter temporarily, to prevent client registration 215 * structure from being destroyed. 216 * 217 * @param regc The client registration structure. 218 */ 219 PJ_DECL(void) pjsip_regc_add_ref( pjsip_regc *regc ); 220 221 222 /** 223 * Decrement temporary busy counter. After this function 224 * is called, client registration structure may have been destroyed 225 * if there's a pending destroy. 226 * 227 * @param regc The client registration structure. 228 * 229 * @return PJ_SUCCESS on success. PJ_EGONE if the registration 230 * structure has been destroyed inside the function. 231 */ 232 PJ_DECL(pj_status_t) pjsip_regc_dec_ref( pjsip_regc *regc ); 233 234 212 235 /** 213 236 * Set callback to be called when the registration received a final response. -
pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c
r6134 r6142 398 398 } 399 399 400 PJ_DEF(void) pjsip_regc_add_ref( pjsip_regc *regc ) 401 { 402 pj_assert(regc); 403 pj_atomic_inc(regc->busy_ctr); 404 } 405 406 PJ_DEF(pj_status_t) pjsip_regc_dec_ref( pjsip_regc *regc ) 407 { 408 pj_assert(regc); 409 if (pj_atomic_dec_and_get(regc->busy_ctr)==0 && regc->_delete_flag) { 410 pjsip_regc_destroy(regc); 411 return PJ_EGONE; 412 } 413 414 return PJ_SUCCESS; 415 } 416 400 417 PJ_DEF(pj_status_t) pjsip_regc_set_credentials( pjsip_regc *regc, 401 418 int count, … … 788 805 * in pjsip_regc_send() or in the callback 789 806 */ 790 pj _atomic_inc(regc->busy_ctr);807 pjsip_regc_add_ref(regc); 791 808 792 809 entry->id = 0; … … 804 821 805 822 /* Delete the record if user destroy regc during the callback. */ 806 if (pj_atomic_dec_and_get(regc->busy_ctr)==0 && regc->_delete_flag) { 807 pjsip_regc_destroy(regc); 808 } 823 pjsip_regc_dec_ref(regc); 809 824 } 810 825 … … 1068 1083 pj_bool_t update_contact = PJ_FALSE; 1069 1084 1070 pj _atomic_inc(regc->busy_ctr);1085 pjsip_regc_add_ref(regc); 1071 1086 pj_lock_acquire(regc->lock); 1072 1087 … … 1368 1383 1369 1384 /* Delete the record if user destroy regc during the callback. */ 1370 if (pj_atomic_dec_and_get(regc->busy_ctr)==0 && regc->_delete_flag) { 1371 pjsip_regc_destroy(regc); 1372 } 1385 pjsip_regc_dec_ref(regc); 1373 1386 } 1374 1387 … … 1380 1393 pj_uint32_t cseq; 1381 1394 1382 pj _atomic_inc(regc->busy_ctr);1395 pjsip_regc_add_ref(regc); 1383 1396 pj_lock_acquire(regc->lock); 1384 1397 … … 1481 1494 1482 1495 /* Delete the record if user destroy regc during the callback. */ 1483 if (pj_atomic_dec_and_get(regc->busy_ctr)==0 && regc->_delete_flag) { 1484 pjsip_regc_destroy(regc); 1485 } 1496 pjsip_regc_dec_ref(regc); 1486 1497 1487 1498 return status; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r6141 r6142 2779 2779 } 2780 2780 2781 /* Increment ref counter and release PJSUA lock here, to avoid 2782 * deadlock while making sure that regc won't be destroyed. 2783 */ 2784 pjsip_regc_add_ref(pjsua_var.acc[acc_id].regc); 2785 PJSUA_UNLOCK(); 2786 2781 2787 //pjsua_process_msg_data(tdata, NULL); 2782 2788 status = pjsip_regc_send( pjsua_var.acc[acc_id].regc, tdata ); 2789 2790 PJSUA_LOCK(); 2791 if (pjsip_regc_dec_ref(pjsua_var.acc[acc_id].regc) == PJ_EGONE) { 2792 /* regc has been deleted. */ 2793 goto on_return; 2794 } 2783 2795 } 2784 2796
Note: See TracChangeset
for help on using the changeset viewer.