]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
POSIX says never to compare pthread_t directly
authorMathieu Rene <mrene@avgs.ca>
Sun, 24 Jan 2010 19:23:58 +0000 (19:23 +0000)
committerMathieu Rene <mrene@avgs.ca>
Sun, 24 Jan 2010 19:23:58 +0000 (19:23 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16501 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_apr.h
src/switch_apr.c
src/switch_core_session.c

index 64ddbd6776ee82f9e0859015e56a69176c1050a9..e39f9cb15aace14f422f190af9007d47b50dfc19 100644 (file)
@@ -50,6 +50,12 @@ typedef pthread_t             switch_thread_id_t;
 
 SWITCH_DECLARE(switch_thread_id_t) switch_thread_self(void);
 
+/*! \brief Compare two thread ids 
+ *  \param tid1 1st Thread ID to compare
+ *  \param tid2 2nd Thread ID to compare
+*/
+SWITCH_DECLARE(int) switch_thread_equal(switch_thread_id_t tid1, switch_thread_id_t tid2);
+
 
 /*
    The pieces of apr we allow ppl to pass around between modules we typedef into our namespace and wrap all the functions
index dc5523968a01535b0a4ef525dc39cda66ee149e0..dfced1e70060d14f3e8c69b50007f7018c220dcd 100644 (file)
@@ -79,6 +79,16 @@ SWITCH_DECLARE(switch_thread_id_t) switch_thread_self(void)
 #endif
 }
 
+SWITCH_DECLARE(int) switch_thread_equal(switch_thread_id_t tid1, switch_thread_id_t tid2)
+{
+#ifdef WIN32 
+       return (tid1 == tid2);
+#else
+       return apr_os_thread_equal(tid1, tid2);
+#endif
+
+}
+
 SWITCH_DECLARE(void) switch_pool_clear(switch_memory_pool_t *p)
 {
        apr_pool_clear(p);
index 10f7d9e6676c7ae96410acd514bf5312f79302c0..7b4692ac3c188886455ef5f2bb43ce0063ad112d 100644 (file)
@@ -1143,10 +1143,7 @@ SWITCH_DECLARE(void) switch_core_session_disable_heartbeat(switch_core_session_t
 
 SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session)
 {
-       if (switch_thread_self() == session->thread_id) {
-               return SWITCH_TRUE;
-       }
-       return SWITCH_FALSE;
+       return switch_thread_equal(switch_thread_self(), session->thread_id) ? SWITCH_TRUE : SWITCH_FALSE;
 }
 
 static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread_t *thread, void *obj)