swrap_mutex_lock(&sockets_mutex); \
swrap_mutex_lock(&socket_reset_mutex); \
swrap_mutex_lock(&first_free_mutex); \
- swrap_mutex_lock(&sockets_si_global); \
+ swrap_mutex_lock_trace(&sockets_si_global); \
swrap_mutex_lock(&autobind_start_mutex); \
swrap_mutex_lock(&pcap_dump_mutex); \
swrap_mutex_lock(&mtu_update_mutex); \
swrap_mutex_unlock(&mtu_update_mutex); \
swrap_mutex_unlock(&pcap_dump_mutex); \
swrap_mutex_unlock(&autobind_start_mutex); \
- swrap_mutex_unlock(&sockets_si_global); \
+ swrap_mutex_unlock_trace(&sockets_si_global); \
swrap_mutex_unlock(&first_free_mutex); \
swrap_mutex_unlock(&socket_reset_mutex); \
swrap_mutex_unlock(&sockets_mutex); \
#define SWRAP_LOCK_SI(si) do { \
struct socket_info_container *sic = SOCKET_INFO_CONTAINER(si); \
if (sic != NULL) { \
- swrap_mutex_lock(&sockets_si_global); \
+ swrap_mutex_lock_trace(&sockets_si_global); \
} else { \
abort(); \
} \
#define SWRAP_UNLOCK_SI(si) do { \
struct socket_info_container *sic = SOCKET_INFO_CONTAINER(si); \
if (sic != NULL) { \
- swrap_mutex_unlock(&sockets_si_global); \
+ swrap_mutex_unlock_trace(&sockets_si_global); \
} else { \
abort(); \
} \
return func;
}
-#define swrap_mutex_lock(m) _swrap_mutex_lock(m, #m, __func__, __LINE__)
-static void _swrap_mutex_lock(pthread_mutex_t *mutex, const char *name, const char *caller, unsigned line)
+#define swrap_mutex_lock(m) _swrap_mutex_lock(m, #m, __func__, __LINE__, false)
+#define swrap_mutex_lock_trace(m) _swrap_mutex_lock(m, #m, __func__, __LINE__, true)
+static void _swrap_mutex_lock(pthread_mutex_t *mutex, const char *name, const char *caller, unsigned line, bool trace)
{
int ret;
+ if (trace) {
+ SWRAP_LOG(SWRAP_LOG_ERROR, "PID(%d):TID(%lld):PPID(%d): %s(%u): Locking pthread mutex(%s) ...",
+ getpid(), (unsigned long long)gettid(), getppid(),
+ caller, line, name);
+ }
ret = pthread_mutex_lock(mutex);
if (ret != 0) {
- SWRAP_LOG(SWRAP_LOG_ERROR, "PID(%d):PPID(%d): %s(%u): Couldn't lock pthread mutex(%s) - %s",
- getpid(), getppid(), caller, line, name, strerror(ret));
+ SWRAP_LOG(SWRAP_LOG_ERROR, "PID(%d):TID(%lld):PPID(%d): %s(%u): Couldn't lock pthread mutex(%s) - %d %s",
+ getpid(), (unsigned long long)gettid(), getppid(),
+ caller, line, name, ret, strerror(ret));
abort();
}
+ if (trace) {
+ SWRAP_LOG(SWRAP_LOG_ERROR, "PID(%d):TID(%lld):PPID(%d): %s(%u): Locked pthread mutex(%s) - %d %s",
+ getpid(), (unsigned long long)gettid(), getppid(),
+ caller, line, name, ret, strerror(ret));
+ }
}
-#define swrap_mutex_unlock(m) _swrap_mutex_unlock(m, #m, __func__, __LINE__)
-static void _swrap_mutex_unlock(pthread_mutex_t *mutex, const char *name, const char *caller, unsigned line)
+#define swrap_mutex_unlock(m) _swrap_mutex_unlock(m, #m, __func__, __LINE__, false)
+#define swrap_mutex_unlock_trace(m) _swrap_mutex_unlock(m, #m, __func__, __LINE__, true)
+static void _swrap_mutex_unlock(pthread_mutex_t *mutex, const char *name, const char *caller, unsigned line, bool trace)
{
int ret;
+ if (trace) {
+ SWRAP_LOG(SWRAP_LOG_ERROR, "PID(%d):TID(%lld):PPID(%d): %s(%u): Unlocking pthread mutex(%s) ...",
+ getpid(), (unsigned long long)gettid(), getppid(),
+ caller, line, name);
+ }
ret = pthread_mutex_unlock(mutex);
if (ret != 0) {
- SWRAP_LOG(SWRAP_LOG_ERROR, "PID(%d):PPID(%d): %s(%u): Couldn't unlock pthread mutex(%s) - %s",
- getpid(), getppid(), caller, line, name, strerror(ret));
+ SWRAP_LOG(SWRAP_LOG_ERROR, "PID(%d):TID(%lld):PPID(%d): %s(%u): Couldn't unlock pthread mutex(%s) - %d %s",
+ getpid(), (unsigned long long)gettid(), getppid(),
+ caller, line, name, ret, strerror(ret));
abort();
}
+ if (trace) {
+ SWRAP_LOG(SWRAP_LOG_ERROR, "PID(%d):TID(%lld):PPID(%d): %s(%u): Unlocked pthread mutex(%s) - %d %s",
+ getpid(), (unsigned long long)gettid(), getppid(),
+ caller, line, name, ret, strerror(ret));
+ }
}
/*
}
swrap_mutex_lock(&first_free_mutex);
- swrap_mutex_lock(&sockets_si_global);
+ swrap_mutex_lock_trace(&sockets_si_global);
first_free = 0;
/* mark the end of the free list */
swrap_set_next_free(&sockets[max_sockets-1].info, -1);
- swrap_mutex_unlock(&sockets_si_global);
+ swrap_mutex_unlock_trace(&sockets_si_global);
swrap_mutex_unlock(&first_free_mutex);
swrap_mutex_unlock(&sockets_mutex);
if (ret != 0) {