Changeset 4587

Show
Ignore:
Timestamp:
11/05/08 15:36:57 (2 months ago)
Author:
martin
Message:

threshhold and ./configure option for lock profiler

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/configure.in

    r4469 r4587  
    375375    [if test x$enableval = xyes; then 
    376376        leak_detective=true 
     377    fi] 
     378) 
     379 
     380AC_ARG_ENABLE( 
     381    [lock-profiler], 
     382    AS_HELP_STRING([--enable-lock-profiling],[enable lock/mutex profiling code (default is NO).]), 
     383    [if test x$enableval = xyes; then 
     384        lock_profiler=true 
    377385    fi] 
    378386) 
     
    900908AM_CONDITIONAL(USE_CISCO_QUIRKS, test x$cisco_quirks = xtrue) 
    901909AM_CONDITIONAL(USE_LEAK_DETECTIVE, test x$leak_detective = xtrue) 
     910AM_CONDITIONAL(USE_LOCK_PROFILER, test x$lock_profiler = xtrue) 
    902911AM_CONDITIONAL(USE_NAT_TRANSPORT, test x$nat_transport = xtrue) 
    903912AM_CONDITIONAL(USE_VENDORID, test x$vendor_id = xtrue) 
  • trunk/src/libstrongswan/Makefile.am

    r4585 r4587  
    6363  AM_CFLAGS += -DLEAK_DETECTIVE 
    6464  libstrongswan_la_SOURCES += utils/leak_detective.c utils/leak_detective.h 
     65endif 
     66 
     67if USE_LOCK_PROFILER 
     68  AM_CFLAGS += -DLOCK_PROFILER 
    6569endif 
    6670 
  • trunk/src/libstrongswan/utils/mutex.c

    r4585 r4587  
    2828#include <errno.h> 
    2929 
     30/** 
     31 * Do not report mutexes with an overall waiting time smaller than this (in us) 
     32 */ 
     33#define PROFILE_TRESHHOLD 1000 
    3034 
    3135typedef struct private_mutex_t private_mutex_t; 
     
    104108 
    105109#ifdef LOCK_PROFILER 
    106  
    107 #include <execinfo.h> 
    108  
    109110/** 
    110111 * Print and cleanup mutex profiler 
     
    112113static void profiler_cleanup(private_mutex_t *this) 
    113114{ 
    114     fprintf(stderr, "waited %d.%06ds in mutex, created at:", 
    115             this->waited.tv_sec, this->waited.tv_usec); 
    116     this->backtrace->log(this->backtrace, stderr); 
     115    if (this->waited.tv_sec > 0 || 
     116        this->waited.tv_usec > PROFILE_TRESHHOLD) 
     117    { 
     118        fprintf(stderr, "waited %d.%06ds in mutex, created at:", 
     119                this->waited.tv_sec, this->waited.tv_usec); 
     120        this->backtrace->log(this->backtrace, stderr); 
     121    } 
    117122    this->backtrace->destroy(this->backtrace); 
    118123}