)
AC_ARG_ENABLE(
+ [lock-profiler],
+ AS_HELP_STRING([--enable-lock-profiling],[enable lock/mutex profiling code (default is NO).]),
+ [if test x$enableval = xyes; then
+ lock_profiler=true
+ fi]
+)
+
+AC_ARG_ENABLE(
[unit-tests],
AS_HELP_STRING([--enable-unit-tests],[enable unit tests on IKEv2 daemon startup (default is NO).]),
[if test x$enableval = xyes; then
AM_CONDITIONAL(USE_SMARTCARD, test x$smartcard = xtrue)
AM_CONDITIONAL(USE_CISCO_QUIRKS, test x$cisco_quirks = xtrue)
AM_CONDITIONAL(USE_LEAK_DETECTIVE, test x$leak_detective = xtrue)
+AM_CONDITIONAL(USE_LOCK_PROFILER, test x$lock_profiler = xtrue)
AM_CONDITIONAL(USE_NAT_TRANSPORT, test x$nat_transport = xtrue)
AM_CONDITIONAL(USE_VENDORID, test x$vendor_id = xtrue)
AM_CONDITIONAL(USE_XAUTH_VID, test x$xauth_vid = xtrue)
#include <time.h>
#include <errno.h>
+/**
+ * Do not report mutexes with an overall waiting time smaller than this (in us)
+ */
+#define PROFILE_TRESHHOLD 1000
typedef struct private_mutex_t private_mutex_t;
typedef struct private_r_mutex_t private_r_mutex_t;
};
#ifdef LOCK_PROFILER
-
-#include <execinfo.h>
-
/**
* Print and cleanup mutex profiler
*/
static void profiler_cleanup(private_mutex_t *this)
{
- fprintf(stderr, "waited %d.%06ds in mutex, created at:",
- this->waited.tv_sec, this->waited.tv_usec);
- this->backtrace->log(this->backtrace, stderr);
+ if (this->waited.tv_sec > 0 ||
+ this->waited.tv_usec > PROFILE_TRESHHOLD)
+ {
+ fprintf(stderr, "waited %d.%06ds in mutex, created at:",
+ this->waited.tv_sec, this->waited.tv_usec);
+ this->backtrace->log(this->backtrace, stderr);
+ }
this->backtrace->destroy(this->backtrace);
}