Ignore:
Timestamp:
Aug 12, 2006 1:58:56 PM (18 years ago)
Author:
bennylp
Message:

Improved logging consistency and added more logging info in verbosity 6

File:
1 edited

Legend:

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

    r674 r675  
    8080    int                 nesting_level; 
    8181    pj_thread_t        *owner; 
     82    char                owner_name[PJ_MAX_OBJ_NAME]; 
    8283#endif 
    8384}; 
     
    979980    PJ_ASSERT_RETURN(mutex, PJ_EINVAL); 
    980981 
     982#if PJ_DEBUG 
     983    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting (mutex owner=%s)",  
     984                                pj_thread_this()->obj_name, 
     985                                mutex->owner_name)); 
     986#else 
    981987    PJ_LOG(6,(mutex->obj_name, "Mutex: thread %s is waiting",  
    982988                                pj_thread_this()->obj_name)); 
     989#endif 
    983990 
    984991    status = pthread_mutex_lock( &mutex->mutex ); 
    985992 
     993 
     994#if PJ_DEBUG 
     995    if (status == PJ_SUCCESS) { 
     996        mutex->owner = pj_thread_this(); 
     997        pj_ansi_strcpy(mutex->owner_name, mutex->owner->obj_name); 
     998        ++mutex->nesting_level; 
     999    } 
     1000 
     1001    PJ_LOG(6,(mutex->obj_name,  
     1002              (status==0 ?  
     1003                "Mutex acquired by thread %s (level=%d)" :  
     1004                "Mutex acquisition FAILED by %s (level=%d)"), 
     1005              pj_thread_this()->obj_name, 
     1006              mutex->nesting_level)); 
     1007#else 
    9861008    PJ_LOG(6,(mutex->obj_name,  
    9871009              (status==0 ? "Mutex acquired by thread %s" : "FAILED by %s"), 
    9881010              pj_thread_this()->obj_name)); 
    989  
    990 #if PJ_DEBUG 
    991     if (status == PJ_SUCCESS) { 
    992         mutex->owner = pj_thread_this(); 
    993         ++mutex->nesting_level; 
    994     } 
    9951011#endif 
    9961012 
     
    10201036    if (--mutex->nesting_level == 0) { 
    10211037        mutex->owner = NULL; 
    1022     } 
    1023 #endif 
    1024  
     1038        mutex->owner_name[0] = '\0'; 
     1039    } 
     1040 
     1041    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s (level=%d)",  
     1042                                pj_thread_this()->obj_name,  
     1043                                mutex->nesting_level)); 
     1044#else 
    10251045    PJ_LOG(6,(mutex->obj_name, "Mutex released by thread %s",  
    10261046                                pj_thread_this()->obj_name)); 
     1047#endif 
    10271048 
    10281049    status = pthread_mutex_unlock( &mutex->mutex ); 
     
    10521073 
    10531074    if (status==0) { 
     1075#if PJ_DEBUG 
     1076        mutex->owner = pj_thread_this(); 
     1077        pj_ansi_strcpy(mutex->owner_name, mutex->owner->obj_name); 
     1078        ++mutex->nesting_level; 
     1079 
     1080        PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s (level=%d)",  
     1081                                   pj_thread_this()->obj_name, 
     1082                                   mutex->nesting_level)); 
     1083#else 
    10541084        PJ_LOG(6,(mutex->obj_name, "Mutex acquired by thread %s",  
    10551085                                  pj_thread_this()->obj_name)); 
    1056  
    1057 #if PJ_DEBUG 
    1058         mutex->owner = pj_thread_this(); 
    1059         ++mutex->nesting_level; 
    10601086#endif 
    10611087    } 
     
    10821108 
    10831109#if PJ_HAS_THREADS 
    1084     PJ_LOG(6,(mutex->obj_name, "Mutex destroyed")); 
     1110    PJ_LOG(6,(mutex->obj_name, "Mutex destroyed by thread %s", 
     1111                               pj_thread_this()->obj_name)); 
    10851112    status = pthread_mutex_destroy( &mutex->mutex ); 
    10861113    if (status == 0) 
Note: See TracChangeset for help on using the changeset viewer.