From c31b8d90a4e4809ada5b60fcdcc93b6ecf9326e4 Mon Sep 17 00:00:00 2001 From: sr Date: Tue, 16 Jul 2013 21:20:07 +0200 Subject: Add debug-lock functions that will helpt to spot deadlocks etc. while developing --- src/server/locks.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/server/locks.h (limited to 'src/server/locks.h') diff --git a/src/server/locks.h b/src/server/locks.h new file mode 100644 index 0000000..9a0a024 --- /dev/null +++ b/src/server/locks.h @@ -0,0 +1,30 @@ +#ifndef _LOCKS_H_ +#define _LOCKS_H_ + +#ifdef _DEBUG + +#include + +#define spin_init( lock, type ) debug_spin_init( #lock, __FILE__, __LINE__, lock, type) +#define spin_lock( lock ) debug_spin_lock( #lock, __FILE__, __LINE__, lock) +#define spin_unlock( lock ) debug_spin_unlock( #lock, __FILE__, __LINE__, lock) +#define spin_destroy( lock ) debug_spin_destroy( #lock, __FILE__, __LINE__, lock) + +int debug_spin_init(const char *name, const char *file, int line, pthread_spinlock_t *lock, int shared); +int debug_spin_lock(const char *name, const char *file, int line, pthread_spinlock_t *lock); +int debug_spin_unlock(const char *name, const char *file, int line, pthread_spinlock_t *lock); +int debug_spin_destory(const char *name, const char *file, int line, pthread_spinlock_t *lock); + +void debug_dump_lock_stats(); +void *debug_thread_watchdog(void *something); + +#else + +#define spin_init( lock, type ) pthread_spin_init(lock, type) +#define spin_lock( lock ) pthread_spin_lock(lock) +#define spin_unlock( lock ) pthread_spin_unlock(lock) +#define spin_destroy( lock ) pthread_spin_destroy(lock) + +#endif + +#endif /* LOCKS_H_ */ -- cgit v1.2.3-55-g7522