diff options
author | sr | 2013-07-18 13:47:01 +0200 |
---|---|---|
committer | sr | 2013-07-18 13:47:01 +0200 |
commit | f2efd7f97baf6ab5d590ac7642bbf7317f8c47ed (patch) | |
tree | 7ed2e5f2ae802742ff59a7d73e6570054df39d78 /src/server/locks.c | |
parent | Remove all glib dependencies from server (diff) | |
download | dnbd3-f2efd7f97baf6ab5d590ac7642bbf7317f8c47ed.tar.gz dnbd3-f2efd7f97baf6ab5d590ac7642bbf7317f8c47ed.tar.xz dnbd3-f2efd7f97baf6ab5d590ac7642bbf7317f8c47ed.zip |
kernel module changes
Diffstat (limited to 'src/server/locks.c')
-rw-r--r-- | src/server/locks.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/server/locks.c b/src/server/locks.c index 050fa4e..9e8d4ad 100644 --- a/src/server/locks.c +++ b/src/server/locks.c @@ -205,32 +205,45 @@ void debug_dump_lock_stats() static void *debug_thread_watchdog(void *something) { - while (!_shutdown) { - time_t now = time(NULL); - pthread_spin_lock( &initdestory ); - for (int i = 0; i < MAXTHREADS; ++i) { - if ( threads[i].tid == 0 ) continue; - const int diff = now - threads[i].time; - if ( diff > 6 && diff < 100000 ) { - printf("\n\n +++++++++ DEADLOCK ++++++++++++\n\n"); - pthread_spin_unlock( &initdestory ); - debug_dump_lock_stats(); - exit(99); + while ( !_shutdown ) { + if (init_done) { + time_t now = time( NULL ); + pthread_spin_lock( &initdestory ); + for (int i = 0; i < MAXTHREADS; ++i) { + if ( threads[i].tid == 0 ) continue; + const int diff = now - threads[i].time; + if ( diff > 6 && diff < 100000 ) { + printf( "\n\n +++++++++ DEADLOCK ++++++++++++\n\n" ); + pthread_spin_unlock( &initdestory ); + debug_dump_lock_stats(); + exit( 99 ); + } } + pthread_spin_unlock( &initdestory ); } - pthread_spin_unlock( &initdestory ); - sleep(10); + sleep( 10 ); } - return NULL; + return NULL ; } +#endif + void debug_locks_start_watchdog() { +#ifdef _DEBUG if ( 0 != pthread_create( &watchdog, NULL, &debug_thread_watchdog, (void *)NULL ) ) { memlogf( "[ERROR] Could not start debug-lock watchdog." ); return; } - pthread_detach( watchdog ); +#endif } +void debug_locks_stop_watchdog() +{ +#ifdef _DEBUG + _shutdown = TRUE; + pthread_spin_lock( &initdestory ); + pthread_spin_unlock( &initdestory ); + pthread_join( watchdog, NULL ); #endif +} |