Ignore:
Timestamp:
Feb 21, 2013 11:26:35 AM (6 years ago)
Author:
bennylp
Message:

Fixed #1617: major synchronization fixes in PJNATH with incorporation of group lock to avoid deadlock and crashes due to race conditions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/src/pjnath-test/test.c

    r3553 r4360  
    3535    pj_ioqueue_t *ioqueue; 
    3636    pj_timer_heap_t *timer_heap; 
     37    pj_lock_t *lock; 
    3738    pj_status_t status; 
    3839 
     
    5051    } 
    5152 
     53    pj_lock_create_recursive_mutex(pool, NULL, &lock); 
     54    pj_timer_heap_set_lock(timer_heap, lock, PJ_TRUE); 
     55 
    5256    pj_stun_config_init(stun_cfg, mem, 0, ioqueue, timer_heap); 
    5357 
     
    106110    st->timer_cnt = pj_timer_heap_count(cfg->timer_heap); 
    107111     
    108     cp = (pj_caching_pool*)mem; 
     112    cp = (pj_caching_pool*)cfg->pf; 
    109113    st->pool_used_cnt = cp->used_count; 
    110114} 
     
    121125        PJ_LOG(3,("", "    error: possibly leaking timer")); 
    122126        rc |= ERR_TIMER_LEAK; 
     127 
     128#if PJ_TIMER_DEBUG 
     129        pj_timer_heap_dump(cfg->timer_heap); 
     130#endif 
    123131    } 
    124132 
     
    149157                      PJ_LOG_HAS_MICRO_SEC; 
    150158 
     159pj_log_func *orig_log_func; 
     160FILE *log_file; 
     161 
     162static void test_log_func(int level, const char *data, int len) 
     163{ 
     164    if (log_file) { 
     165        fwrite(data, len, 1, log_file); 
     166    } 
     167    if (level <= 3) 
     168        orig_log_func(level, data, len); 
     169} 
     170 
    151171static int test_inner(void) 
    152172{ 
     
    159179    pj_log_set_level(3); 
    160180    pj_log_set_decor(param_log_decor); 
     181#elif 1 
     182    log_file = fopen("pjnath-test.log", "wt"); 
     183    pj_log_set_level(5); 
     184    orig_log_func = pj_log_get_log_func(); 
     185    pj_log_set_log_func(&test_log_func); 
    161186#endif 
    162187 
     
    190215#endif 
    191216 
     217#if INCLUDE_CONCUR_TEST 
     218    DO_TEST(concur_test()); 
     219#endif 
     220 
    192221on_return: 
     222    if (log_file) 
     223        fclose(log_file); 
    193224    return rc; 
    194225} 
Note: See TracChangeset for help on using the changeset viewer.