From: ftillier Date: Fri, 2 Sep 2005 22:18:06 +0000 (+0000) Subject: Allow cl_timer_stop to be called from timer callback thread. X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=b4faebe91ea405e3d924c645e9265a85733787bf;p=~shefty%2Frdma-win.git Allow cl_timer_stop to be called from timer callback thread. git-svn-id: svn://openib.tc.cornell.edu/gen1@59 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/core/complib/user/cl_timer.c b/trunk/core/complib/user/cl_timer.c index 5c19cb84..9df169f4 100644 --- a/trunk/core/complib/user/cl_timer.c +++ b/trunk/core/complib/user/cl_timer.c @@ -44,8 +44,11 @@ __timer_callback( UNUSED_PARAM( timer_signalled ); p_timer->timeout_time = 0; + p_timer->thread_id = GetCurrentThreadId(); (p_timer->pfn_callback)( (void*)p_timer->context ); + + p_timer->thread_id = 0; } @@ -55,6 +58,7 @@ cl_timer_construct( { p_timer->h_timer = NULL; p_timer->timeout_time = 0; + p_timer->thread_id = 0; } @@ -134,7 +138,7 @@ cl_timer_stop( { CL_ASSERT( p_timer ); - if( p_timer->h_timer ) + if( p_timer->h_timer && p_timer->thread_id != GetCurrentThreadId() ) { /* Make sure we block until the timer is cancelled. */ DeleteTimerQueueTimer( NULL, p_timer->h_timer, INVALID_HANDLE_VALUE ); diff --git a/trunk/inc/user/complib/cl_timer_osd.h b/trunk/inc/user/complib/cl_timer_osd.h index f68004d6..0a023ba6 100644 --- a/trunk/inc/user/complib/cl_timer_osd.h +++ b/trunk/inc/user/complib/cl_timer_osd.h @@ -46,6 +46,7 @@ typedef struct _cl_timer cl_pfn_timer_callback_t pfn_callback; const void *context; uint64_t timeout_time; + DWORD thread_id; } cl_timer_t;