Allow cl_timer_stop to be called from timer callback thread.
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 2 Sep 2005 22:18:06 +0000 (22:18 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 2 Sep 2005 22:18:06 +0000 (22:18 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@59 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/complib/user/cl_timer.c
inc/user/complib/cl_timer_osd.h

index 5c19cb8..9df169f 100644 (file)
@@ -44,8 +44,11 @@ __timer_callback(
        UNUSED_PARAM( timer_signalled );\r
 \r
        p_timer->timeout_time = 0;\r
+       p_timer->thread_id = GetCurrentThreadId();\r
 \r
        (p_timer->pfn_callback)( (void*)p_timer->context );\r
+\r
+       p_timer->thread_id = 0;\r
 }\r
 \r
 \r
@@ -55,6 +58,7 @@ cl_timer_construct(
 {\r
        p_timer->h_timer = NULL;\r
        p_timer->timeout_time = 0;\r
+       p_timer->thread_id = 0;\r
 }\r
 \r
 \r
@@ -134,7 +138,7 @@ cl_timer_stop(
 {\r
        CL_ASSERT( p_timer );\r
 \r
-       if( p_timer->h_timer )\r
+       if( p_timer->h_timer && p_timer->thread_id != GetCurrentThreadId() )\r
        {\r
                /* Make sure we block until the timer is cancelled. */\r
                DeleteTimerQueueTimer( NULL, p_timer->h_timer, INVALID_HANDLE_VALUE );\r
index f68004d..0a023ba 100644 (file)
@@ -46,6 +46,7 @@ typedef struct _cl_timer
        cl_pfn_timer_callback_t pfn_callback;\r
        const void                              *context;\r
        uint64_t                                timeout_time;\r
+       DWORD                                   thread_id;\r
 \r
 } cl_timer_t;\r
 \r