Changeset 3854


Ignore:
Timestamp:
Oct 25, 2011 12:12:44 PM (13 years ago)
Author:
bennylp
Message:

More re #1394: handle the case when clock_stop() is called from within the clock callback itself

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/clock_thread.c

    r3840 r3854  
    222222    clock->quitting = PJ_FALSE; 
    223223 
    224     if ((clock->options & PJMEDIA_CLOCK_NO_ASYNC) == 0) { 
     224    if ((clock->options & PJMEDIA_CLOCK_NO_ASYNC) == 0 && !clock->thread) { 
    225225        status = pj_thread_create(clock->pool, "clock", &clock_thread, clock, 
    226226                                  0, 0, &clock->thread); 
     
    246246 
    247247    if (clock->thread) { 
    248         pj_thread_join(clock->thread); 
    249         clock->thread = NULL; 
     248        if (pj_thread_join(clock->thread) == PJ_SUCCESS) { 
     249            clock->thread = NULL; 
     250        } else { 
     251            clock->quitting = PJ_FALSE; 
     252        } 
    250253    } 
    251254 
     
    375378            (*clock->cb)(&clock->timestamp, clock->user_data); 
    376379 
     380        /* Best effort way to detect if we've been destroyed in the callback */ 
     381        if (clock->quitting) 
     382            break; 
     383 
    377384        /* Increment timestamp */ 
    378385        clock->timestamp.u64 += clock->timestamp_inc; 
Note: See TracChangeset for help on using the changeset viewer.