]> git.itanic.dy.fi Git - rrdd/blobdiff - process.h
process: Add debug wrappers for pthread mutex operations
[rrdd] / process.h
index ae9db12b97457f90e5d4256c0e42e3ba5ffdb506..2589ea9a5251174c6632bf0b87620912c54e1cc3 100644 (file)
--- a/process.h
+++ b/process.h
@@ -9,6 +9,7 @@
 #include <error.h>
 #include <errno.h>
 #include <stdint.h>
+#include <pthread.h>
 
 struct event_handler;
 
@@ -21,6 +22,14 @@ struct event_handler {
        char *name;
 };
 
+struct mutex {
+       pthread_mutex_t lock;
+       int line;
+       char *file;
+       time_t lock_time;
+       char *name;
+};
+
 int register_event_handler(struct event_handler *handler);
 
 int get_child_count(void);
@@ -37,5 +46,12 @@ int run_piped(const char *cmd, char *const argv[],
 int run_piped_stream(const char *cmd, char *const argv[],
                     FILE **stdinf, FILE **stdoutf, FILE **stderrf);
 
+void _mutex_lock_acquired(struct mutex *lock, char *file, int line);
+int _mutex_lock(struct mutex *lock, char *file, int line);
+int _mutex_unlock(struct mutex *lock);
+
+#define mutex_lock(lock) _mutex_lock(lock, __FILE__, __LINE__)
+#define mutex_unlock(lock) _mutex_unlock(lock)
+#define mutex_lock_acquired(lock) _mutex_lock_acquired(lock, __FILE__, __LINE__)
 
 #endif