Changeset 958 for pjproject


Ignore:
Timestamp:
Feb 17, 2007 12:30:24 AM (18 years ago)
Author:
bennylp
Message:

Fixed ticket #107: deadlock with ioqueue/IOCP unregistration when unregistration is done in the callback

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/ioqueue_winnt.c

    r821 r958  
    667667PJ_DEF(pj_status_t) pj_ioqueue_unregister( pj_ioqueue_key_t *key ) 
    668668{ 
     669    unsigned i; 
     670    enum { RETRY = 10 }; 
     671 
    669672    PJ_ASSERT_RETURN(key, PJ_EINVAL); 
    670673 
     
    714717     * an ugly solution.. 
    715718     */ 
    716     while (pj_atomic_get(key->ref_count) != 1) 
     719    //This will loop forever if unregistration is done on the callback. 
     720    //Doing this with RETRY I think should solve the IOCP setting the  
     721    //socket signalled, without causing the deadlock. 
     722    //while (pj_atomic_get(key->ref_count) != 1) 
     723    //  pj_thread_sleep(0); 
     724    for (i=0; pj_atomic_get(key->ref_count) != 1 && i<RETRY; ++i) 
    717725        pj_thread_sleep(0); 
    718726 
     
    755763    /* Check the closing keys only when there's no activity and when there are 
    756764     * pending closing keys. 
    757      */ 
    758     if (event_count == 0 && !pj_list_empty(&ioqueue->closing_list)) { 
     765     * blp: 
     766     *  no, always check the list. Otherwise on busy activity, this will cause 
     767     *  ioqueue to reject new registration. 
     768     */ 
     769    if (/*event_count == 0 &&*/ !pj_list_empty(&ioqueue->closing_list)) { 
    759770        pj_time_val now; 
    760771        pj_ioqueue_key_t *key; 
Note: See TracChangeset for help on using the changeset viewer.