From e4d08afc6810ab1fa0833a630d9b24bf3c63c988 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Mon, 18 Feb 2013 23:00:48 -0800 Subject: [PATCH] Timeline: Cancel unresponsive disk_threads. --- nonlib/Thread.C | 7 +++++++ nonlib/Thread.H | 1 + timeline/src/Engine/Disk_Stream.C | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/nonlib/Thread.C b/nonlib/Thread.C index cd64e04..2117f87 100644 --- a/nonlib/Thread.C +++ b/nonlib/Thread.C @@ -110,6 +110,13 @@ Thread::detach ( void ) _thread = 0; } +void +Thread::cancel ( void ) +{ + pthread_cancel( _thread ); + _thread = 0; +} + void Thread::join ( void ) { diff --git a/nonlib/Thread.H b/nonlib/Thread.H index 4c27840..feb6b68 100644 --- a/nonlib/Thread.H +++ b/nonlib/Thread.H @@ -52,6 +52,7 @@ public: bool clone ( void *(*entry_point)(void *), void *arg ); void detach ( void ); void join ( void ); + void cancel ( void ); void exit ( void *retval = 0 ); }; diff --git a/timeline/src/Engine/Disk_Stream.C b/timeline/src/Engine/Disk_Stream.C index 7b37242..359a072 100644 --- a/timeline/src/Engine/Disk_Stream.C +++ b/timeline/src/Engine/Disk_Stream.C @@ -155,12 +155,14 @@ Disk_Stream::shutdown ( void ) if ( total_ms > 100 ) { - WARNING("Disk_Stream thread has taken longer than %ims to respond to terminate signal.", total_ms ); + WARNING("Disk_Stream thread has taken longer than %ims to respond to terminate signal. Canceling", total_ms ); + _thread.cancel(); break; } } - _thread.join(); + if ( ! _terminate ) + _thread.join(); sem_destroy( &_blocks );