Ignore:
Timestamp:
Nov 3, 2017 6:54:54 AM (6 years ago)
Author:
nanang
Message:

Fix #2055:

  • Updated active socket to avoid double ioqueue key unregistration.
  • Updated ioqueue to avoid double ioq key unregistration (select & epoll only, winnt & uwp does not seem to be affected).
  • Added check for potential 'negative' ioqueue->count.
File:
1 edited

Legend:

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

    r5119 r5680  
    297297PJ_DEF(pj_status_t) pj_activesock_close(pj_activesock_t *asock) 
    298298{ 
     299    pj_ioqueue_key_t *key; 
     300    pj_bool_t unregister = PJ_FALSE; 
     301 
    299302    PJ_ASSERT_RETURN(asock, PJ_EINVAL); 
    300303    asock->shutdown = SHUT_RX | SHUT_TX; 
    301     if (asock->key) { 
    302         pj_ioqueue_unregister(asock->key); 
     304 
     305    /* Avoid double unregistration on the key */ 
     306    key = asock->key; 
     307    if (key) { 
     308        pj_ioqueue_lock_key(key); 
     309        unregister = (asock->key != NULL); 
     310        asock->key = NULL; 
     311        pj_ioqueue_unlock_key(key); 
     312    } 
     313 
     314    if (unregister) { 
     315        pj_ioqueue_unregister(key); 
    303316 
    304317#if defined(PJ_IPHONE_OS_HAS_MULTITASKING_SUPPORT) && \ 
     
    306319        activesock_destroy_iphone_os_stream(asock); 
    307320#endif   
    308  
    309         asock->key = NULL; 
    310321    } 
    311322    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.