Ignore:
Timestamp:
Jul 2, 2009 8:24:22 AM (13 years ago)
Author:
bennylp
Message:

Ticket #913: Concurrency problem in select ioqueue may corrupt descriptor set

  • fixed the concurrency problem
  • also fixed ioqueue unregister test in pjlib-test
File:
1 edited

Legend:

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

    r2394 r2826  
    688688 
    689689    pj_mutex_lock(key->mutex); 
     690    /* Check again. Handle may have been closed after the previous check 
     691     * in multithreaded app. If we add bad handle to the set it will 
     692     * corrupt the ioqueue set. See #913 
     693     */ 
     694    if (IS_CLOSING(key)) { 
     695        pj_mutex_unlock(key->mutex); 
     696        return PJ_ECANCELLED; 
     697    } 
    690698    pj_list_insert_before(&key->read_list, read_op); 
    691699    ioqueue_add_to_set(key->ioqueue, key, READABLE_EVENT); 
     
    756764 
    757765    pj_mutex_lock(key->mutex); 
     766    /* Check again. Handle may have been closed after the previous check 
     767     * in multithreaded app. If we add bad handle to the set it will 
     768     * corrupt the ioqueue set. See #913 
     769     */ 
     770    if (IS_CLOSING(key)) { 
     771        pj_mutex_unlock(key->mutex); 
     772        return PJ_ECANCELLED; 
     773    } 
    758774    pj_list_insert_before(&key->read_list, read_op); 
    759775    ioqueue_add_to_set(key->ioqueue, key, READABLE_EVENT); 
     
    862878     
    863879    pj_mutex_lock(key->mutex); 
     880    /* Check again. Handle may have been closed after the previous check 
     881     * in multithreaded app. If we add bad handle to the set it will 
     882     * corrupt the ioqueue set. See #913 
     883     */ 
     884    if (IS_CLOSING(key)) { 
     885        pj_mutex_unlock(key->mutex); 
     886        return PJ_ECANCELLED; 
     887    } 
    864888    pj_list_insert_before(&key->write_list, write_op); 
    865889    ioqueue_add_to_set(key->ioqueue, key, WRITEABLE_EVENT); 
     
    9791003     
    9801004    pj_mutex_lock(key->mutex); 
     1005    /* Check again. Handle may have been closed after the previous check 
     1006     * in multithreaded app. If we add bad handle to the set it will 
     1007     * corrupt the ioqueue set. See #913 
     1008     */ 
     1009    if (IS_CLOSING(key)) { 
     1010        pj_mutex_unlock(key->mutex); 
     1011        return PJ_ECANCELLED; 
     1012    } 
    9811013    pj_list_insert_before(&key->write_list, write_op); 
    9821014    ioqueue_add_to_set(key->ioqueue, key, WRITEABLE_EVENT); 
     
    10481080 
    10491081    pj_mutex_lock(key->mutex); 
     1082    /* Check again. Handle may have been closed after the previous check 
     1083     * in multithreaded app. If we add bad handle to the set it will 
     1084     * corrupt the ioqueue set. See #913 
     1085     */ 
     1086    if (IS_CLOSING(key)) { 
     1087        pj_mutex_unlock(key->mutex); 
     1088        return PJ_ECANCELLED; 
     1089    } 
    10501090    pj_list_insert_before(&key->accept_list, accept_op); 
    10511091    ioqueue_add_to_set(key->ioqueue, key, READABLE_EVENT); 
     
    10841124            /* Pending! */ 
    10851125            pj_mutex_lock(key->mutex); 
     1126            /* Check again. Handle may have been closed after the previous  
     1127             * check in multithreaded app. See #913 
     1128             */ 
     1129            if (IS_CLOSING(key)) { 
     1130                pj_mutex_unlock(key->mutex); 
     1131                return PJ_ECANCELLED; 
     1132            } 
    10861133            key->connecting = PJ_TRUE; 
    10871134            ioqueue_add_to_set(key->ioqueue, key, WRITEABLE_EVENT); 
Note: See TracChangeset for help on using the changeset viewer.