- Timestamp:
- Mar 6, 2015 6:09:22 AM (10 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/lock.h
r4359 r4992 219 219 220 220 /** 221 * Create a group lock object, with the specified destructor handler, to be 222 * called by the group lock when it is about to be destroyed. Initially the 223 * group lock will have reference counter of one. 224 * 225 * @param pool The group lock only uses the pool parameter to get 226 * the pool factory, from which it will create its own 227 * pool. 228 * @param cfg Optional configuration. 229 * @param member A pointer to be passed to the handler. 230 * @param handler The destroy handler. 231 * @param p_grp_lock Pointer to receive the newly created group lock. 232 * 233 * @return PJ_SUCCESS or the appropriate error code. 234 */ 235 PJ_DECL(pj_status_t) pj_grp_lock_create_w_handler(pj_pool_t *pool, 236 const pj_grp_lock_config *cfg, 237 void *member, 238 void (*handler)(void *member), 239 pj_grp_lock_t **p_grp_lock); 240 241 /** 221 242 * Forcibly destroy the group lock, ignoring the reference counter value. 222 243 * -
pjproject/trunk/pjlib/src/pj/lock.c
r4613 r4992 336 336 } 337 337 338 static pj_status_t grp_lock_add_handler( pj_grp_lock_t *glock, 339 pj_pool_t *pool, 340 void *comp, 341 void (*destroy)(void *comp), 342 pj_bool_t acquire_lock) 343 { 344 grp_destroy_callback *cb; 345 346 if (acquire_lock) 347 grp_lock_acquire(glock); 348 349 if (pool == NULL) 350 pool = glock->pool; 351 352 cb = PJ_POOL_ZALLOC_T(pool, grp_destroy_callback); 353 cb->comp = comp; 354 cb->handler = destroy; 355 pj_list_push_back(&glock->destroy_list, cb); 356 357 if (acquire_lock) 358 grp_lock_release(glock); 359 360 return PJ_SUCCESS; 361 } 362 338 363 static pj_status_t grp_lock_destroy(LOCK_OBJ *p) 339 364 { … … 428 453 } 429 454 455 PJ_DEF(pj_status_t) pj_grp_lock_create_w_handler( pj_pool_t *pool, 456 const pj_grp_lock_config *cfg, 457 void *member, 458 void (*handler)(void *member), 459 pj_grp_lock_t **p_grp_lock) 460 { 461 pj_status_t status; 462 463 status = pj_grp_lock_create(pool, cfg, p_grp_lock); 464 if (status == PJ_SUCCESS) { 465 grp_lock_add_handler(*p_grp_lock, pool, member, handler, PJ_FALSE); 466 } 467 468 return status; 469 } 470 430 471 PJ_DEF(pj_status_t) pj_grp_lock_destroy( pj_grp_lock_t *grp_lock) 431 472 { … … 477 518 void (*destroy)(void *comp)) 478 519 { 479 grp_destroy_callback *cb; 480 481 grp_lock_acquire(glock); 482 483 if (pool == NULL) 484 pool = glock->pool; 485 486 cb = PJ_POOL_ZALLOC_T(pool, grp_destroy_callback); 487 cb->comp = comp; 488 cb->handler = destroy; 489 pj_list_push_back(&glock->destroy_list, cb); 490 491 grp_lock_release(glock); 492 return PJ_SUCCESS; 520 return grp_lock_add_handler(glock, pool, comp, destroy, PJ_TRUE); 493 521 } 494 522 -
pjproject/trunk/pjsip/src/pjsip/sip_transaction.c
r4964 r4992 1008 1008 if (grp_lock) { 1009 1009 tsx->grp_lock = grp_lock; 1010 1011 pj_grp_lock_add_ref(tsx->grp_lock); 1012 pj_grp_lock_add_handler(tsx->grp_lock, tsx->pool, tsx, &tsx_on_destroy); 1010 1013 } else { 1011 status = pj_grp_lock_create(pool, NULL, &tsx->grp_lock); 1014 status = pj_grp_lock_create_w_handler(pool, NULL, tsx, &tsx_on_destroy, 1015 &tsx->grp_lock); 1012 1016 if (status != PJ_SUCCESS) { 1013 1017 pjsip_endpt_release_pool(mod_tsx_layer.endpt, pool); 1014 1018 return status; 1015 1019 } 1016 } 1017 1018 pj_grp_lock_add_ref(tsx->grp_lock); 1019 pj_grp_lock_add_handler(tsx->grp_lock, tsx->pool, tsx, &tsx_on_destroy); 1020 1021 pj_grp_lock_add_ref(tsx->grp_lock); 1022 } 1020 1023 1021 1024 status = pj_mutex_create_simple(pool, tsx->obj_name, &tsx->mutex_b); … … 1309 1312 1310 1313 1311 /* Lock transaction. */ 1312 pj_grp_lock_acquire(tsx->grp_lock); 1314 /* Lock transaction. 1315 * We don't need to lock the group lock if none was supplied, while the 1316 * newly created group lock has not been exposed. 1317 */ 1318 if (grp_lock) 1319 pj_grp_lock_acquire(tsx->grp_lock); 1313 1320 1314 1321 /* Role is UAC. */ … … 1376 1383 status = pjsip_get_request_dest(tdata, &dst_info); 1377 1384 if (status != PJ_SUCCESS) { 1378 pj_grp_lock_release(tsx->grp_lock); 1385 if (grp_lock) 1386 pj_grp_lock_release(tsx->grp_lock); 1379 1387 tsx_shutdown(tsx); 1380 1388 return status; … … 1388 1396 pj_assert(!"Bug in branch_param generator (i.e. not unique)"); 1389 1397 */ 1390 pj_grp_lock_release(tsx->grp_lock); 1398 if (grp_lock) 1399 pj_grp_lock_release(tsx->grp_lock); 1391 1400 tsx_shutdown(tsx); 1392 1401 return status; … … 1395 1404 1396 1405 /* Unlock transaction and return. */ 1397 pj_grp_lock_release(tsx->grp_lock); 1406 if (grp_lock) 1407 pj_grp_lock_release(tsx->grp_lock); 1398 1408 1399 1409 pj_log_push_indent();
Note: See TracChangeset
for help on using the changeset viewer.