diff --git a/pclsync/debug/pfs_debug.c b/pclsync/debug/pfs_debug.c index e5ead10..868b598 100644 --- a/pclsync/debug/pfs_debug.c +++ b/pclsync/debug/pfs_debug.c @@ -45,3 +45,10 @@ void pfs_debug_register_signal_handlers() { sa.sa_flags = 0; sigaction(SIGUSR1, &sa, NULL); } + +void pfs_debug_check_lock_order(const char *file, unsigned long line) { + if (!psql_locked()) { + pdbg_logf(D_ERROR, "lock ordering violation: pfs_lock_file called without psql_lock at %s:%lu", file, line); + abort(); + } +} diff --git a/pclsync/pfs.c b/pclsync/pfs.c index 6d22621..9e07c16 100644 --- a/pclsync/pfs.c +++ b/pclsync/pfs.c @@ -117,6 +117,7 @@ __attribute__((weak)) void pfs_debug_init_file_mutex(pthread_mutex_t *m) { } __attribute__((weak)) void pfs_debug_dump_internals() {} __attribute__((weak)) void pfs_debug_register_signal_handlers() {} +__attribute__((weak)) void pfs_debug_check_lock_order(const char *file, unsigned long line) {} static int pfs_ftruncate_of_locked(psync_openfile_t *of, fuse_off_t size); diff --git a/pclsync/pfs.h b/pclsync/pfs.h index 0ddf019..b79b1af 100644 --- a/pclsync/pfs.h +++ b/pclsync/pfs.h @@ -146,10 +146,7 @@ typedef struct { extern PSYNC_THREAD const char *psync_thread_name; static inline int pfs_do_lock_file(psync_openfile_t *of, const char *file, unsigned long line) { - if (!psql_locked()) { - pdbg_logf(D_ERROR, "lock ordering violation: pfs_lock_file called without psql_lock at %s:%lu", file, line); - abort(); - } + pfs_debug_check_lock_order(file, line); if (unlikely(pthread_mutex_trylock(&of->mutex))) { struct timespec tm; clock_gettime(CLOCK_REALTIME, &tm); @@ -201,6 +198,7 @@ void pfs_clean_tasks(); void pfs_debug_init_file_mutex(pthread_mutex_t *m); void pfs_debug_dump_internals(); void pfs_debug_register_signal_handlers(); +void pfs_debug_check_lock_order(const char *file, unsigned long line); extern volatile sig_atomic_t shutdown_requested;