Changeset 4434
- Timestamp:
- Mar 11, 2013 5:27:23 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/ioqueue_epoll.c
- Property svn:mergeinfo set to False
r4359 r4434 36 36 #include <pj/sock.h> 37 37 #include <pj/compat/socket.h> 38 #include <pj/rand.h> 38 39 39 40 #if !defined(PJ_LINUX_KERNEL) || PJ_LINUX_KERNEL==0 … … 350 351 * Register a socket to ioqueue. 351 352 */ 352 PJ_DEF(pj_status_t) pj_ioqueue_register_sock (pj_pool_t *pool,353 PJ_DEF(pj_status_t) pj_ioqueue_register_sock2(pj_pool_t *pool, 353 354 pj_ioqueue_t *ioqueue, 354 355 pj_sock_t sock, 356 pj_grp_lock_t *grp_lock, 355 357 void *user_data, 356 358 const pj_ioqueue_callback *cb, … … 404 406 #endif 405 407 406 rc = ioqueue_init_key(pool, ioqueue, key, sock, user_data, cb);408 rc = ioqueue_init_key(pool, ioqueue, key, sock, grp_lock, user_data, cb); 407 409 if (rc != PJ_SUCCESS) { 408 410 key = NULL; … … 438 440 439 441 on_return: 442 if (rc != PJ_SUCCESS) { 443 if (key->grp_lock) 444 pj_grp_lock_dec_ref_dbg(key->grp_lock, "ioqueue", 0); 445 } 440 446 *p_key = key; 441 447 pj_lock_release(ioqueue->lock); 442 448 443 449 return rc; 450 } 451 452 PJ_DEF(pj_status_t) pj_ioqueue_register_sock( pj_pool_t *pool, 453 pj_ioqueue_t *ioqueue, 454 pj_sock_t sock, 455 void *user_data, 456 const pj_ioqueue_callback *cb, 457 pj_ioqueue_key_t **p_key) 458 { 459 return pj_ioqueue_register_sock2(pool, ioqueue, sock, NULL, user_data, 460 cb, p_key); 444 461 } 445 462 … … 498 515 * deadlock. 499 516 */ 500 pj_ lock_acquire(key->lock);517 pj_ioqueue_lock_key(key); 501 518 502 519 /* Also lock ioqueue */ … … 532 549 533 550 /* Done. */ 534 pj_lock_release(key->lock); 551 if (key->grp_lock) { 552 /* just dec_ref and unlock. we will set grp_lock to NULL 553 * elsewhere */ 554 pj_grp_lock_t *grp_lock = key->grp_lock; 555 // Don't set grp_lock to NULL otherwise the other thread 556 // will crash. Just leave it as dangling pointer, but this 557 // should be safe 558 //key->grp_lock = NULL; 559 pj_grp_lock_dec_ref_dbg(grp_lock, "ioqueue", 0); 560 pj_grp_lock_release(grp_lock); 561 } else { 562 pj_ioqueue_unlock_key(key); 563 } 535 564 #else 565 if (key->grp_lock) { 566 /* set grp_lock to NULL and unlock */ 567 pj_grp_lock_t *grp_lock = key->grp_lock; 568 // Don't set grp_lock to NULL otherwise the other thread 569 // will crash. Just leave it as dangling pointer, but this 570 // should be safe 571 //key->grp_lock = NULL; 572 pj_grp_lock_dec_ref_dbg(grp_lock, "ioqueue", 0); 573 pj_grp_lock_release(grp_lock); 574 } else { 575 pj_ioqueue_unlock_key(key); 576 } 577 536 578 pj_lock_destroy(key->lock); 537 579 #endif … … 593 635 if (PJ_TIME_VAL_GTE(now, h->free_time)) { 594 636 pj_list_erase(h); 637 // Don't set grp_lock to NULL otherwise the other thread 638 // will crash. Just leave it as dangling pointer, but this 639 // should be safe 640 //h->grp_lock = NULL; 595 641 pj_list_push_back(&ioqueue->free_list, h); 596 642 } … … 710 756 } 711 757 } 758 for (i=0; i<processed; ++i) { 759 if (queue[i].key->grp_lock) 760 pj_grp_lock_add_ref_dbg(queue[i].key->grp_lock, "ioqueue", 0); 761 } 762 763 PJ_RACE_ME(5); 764 712 765 pj_lock_release(ioqueue->lock); 766 767 PJ_RACE_ME(5); 713 768 714 769 /* Now process the events. */ … … 732 787 decrement_counter(queue[i].key); 733 788 #endif 789 790 if (queue[i].key->grp_lock) 791 pj_grp_lock_dec_ref_dbg(queue[i].key->grp_lock, 792 "ioqueue", 0); 734 793 } 735 794
Note: See TracChangeset
for help on using the changeset viewer.