Changeset 5435 for pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
- Timestamp:
- Aug 30, 2016 8:40:18 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r5398 r5435 196 196 197 197 /* 198 * Add reference to INVITE session. 199 */ 200 PJ_DEF(pj_status_t) pjsip_inv_add_ref( pjsip_inv_session *inv ) 201 { 202 PJ_ASSERT_RETURN(inv && inv->ref_cnt, PJ_EINVAL); 203 204 pj_atomic_inc(inv->ref_cnt); 205 206 return PJ_SUCCESS; 207 } 208 209 static void inv_session_destroy(pjsip_inv_session *inv) 210 { 211 if (inv->last_ack) { 212 pjsip_tx_data_dec_ref(inv->last_ack); 213 inv->last_ack = NULL; 214 } 215 if (inv->invite_req) { 216 pjsip_tx_data_dec_ref(inv->invite_req); 217 inv->invite_req = NULL; 218 } 219 if (inv->pending_bye) { 220 pjsip_tx_data_dec_ref(inv->pending_bye); 221 inv->pending_bye = NULL; 222 } 223 pjsip_100rel_end_session(inv); 224 pjsip_timer_end_session(inv); 225 pjsip_dlg_dec_session(inv->dlg, &mod_inv.mod); 226 227 /* Release the flip-flop pools */ 228 pj_pool_release(inv->pool_prov); 229 inv->pool_prov = NULL; 230 pj_pool_release(inv->pool_active); 231 inv->pool_active = NULL; 232 233 pj_atomic_destroy(inv->ref_cnt); 234 inv->ref_cnt = NULL; 235 } 236 237 /* 238 * Decrease INVITE session reference, destroy it when the reference count 239 * reaches zero. 240 */ 241 PJ_DEF(pj_status_t) pjsip_inv_dec_ref( pjsip_inv_session *inv ) 242 { 243 pj_atomic_value_t ref_cnt; 244 245 PJ_ASSERT_RETURN(inv && inv->ref_cnt, PJ_EINVAL); 246 247 ref_cnt = pj_atomic_dec_and_get(inv->ref_cnt); 248 pj_assert( ref_cnt >= 0); 249 if (ref_cnt == 0) { 250 inv_session_destroy(inv); 251 return PJ_EGONE; 252 } 253 return PJ_SUCCESS; 254 } 255 256 /* 198 257 * Set session state. 199 258 */ … … 262 321 prev_state != PJSIP_INV_STATE_DISCONNECTED) 263 322 { 264 if (inv->last_ack) { 265 pjsip_tx_data_dec_ref(inv->last_ack); 266 inv->last_ack = NULL; 267 } 268 if (inv->invite_req) { 269 pjsip_tx_data_dec_ref(inv->invite_req); 270 inv->invite_req = NULL; 271 } 272 if (inv->pending_bye) { 273 pjsip_tx_data_dec_ref(inv->pending_bye); 274 inv->pending_bye = NULL; 275 } 276 pjsip_100rel_end_session(inv); 277 pjsip_timer_end_session(inv); 278 pjsip_dlg_dec_session(inv->dlg, &mod_inv.mod); 279 280 /* Release the flip-flop pools */ 281 pj_pool_release(inv->pool_prov); 282 inv->pool_prov = NULL; 283 pj_pool_release(inv->pool_active); 284 inv->pool_active = NULL; 323 pjsip_inv_dec_ref(inv); 285 324 } 286 325 } … … 839 878 pj_assert(inv != NULL); 840 879 880 status = pj_atomic_create(dlg->pool, 0, &inv->ref_cnt); 881 if (status != PJ_SUCCESS) { 882 pjsip_dlg_dec_lock(dlg); 883 return status; 884 } 885 841 886 inv->pool = dlg->pool; 842 887 inv->role = PJSIP_ROLE_UAC; … … 882 927 883 928 /* Done */ 929 pjsip_inv_add_ref(inv); 884 930 *p_inv = inv; 885 931 … … 1472 1518 pj_assert(inv != NULL); 1473 1519 1520 status = pj_atomic_create(dlg->pool, 0, &inv->ref_cnt); 1521 if (status != PJ_SUCCESS) { 1522 pjsip_dlg_dec_lock(dlg); 1523 return status; 1524 } 1525 1474 1526 inv->pool = dlg->pool; 1475 1527 inv->role = PJSIP_ROLE_UAS; … … 1541 1593 1542 1594 /* Done */ 1595 pjsip_inv_add_ref(inv); 1543 1596 pjsip_dlg_dec_lock(dlg); 1544 1597 *p_inv = inv;
Note: See TracChangeset
for help on using the changeset viewer.