Revision
16501
Author
mrene
Date
2010-01-24 13:23:58 -0600 (Sun, 24 Jan 2010)

Log Message

POSIX says never to compare pthread_t directly

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_apr.h (16500 => 16501)


--- freeswitch/trunk/src/include/switch_apr.h	2010-01-24 19:04:48 UTC (rev 16500)
+++ freeswitch/trunk/src/include/switch_apr.h	2010-01-24 19:23:58 UTC (rev 16501)
@@ -50,7 +50,13 @@
 
 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
    any other apr code should be as hidden as possible.

Modified: freeswitch/trunk/src/switch_apr.c (16500 => 16501)


--- freeswitch/trunk/src/switch_apr.c	2010-01-24 19:04:48 UTC (rev 16500)
+++ freeswitch/trunk/src/switch_apr.c	2010-01-24 19:23:58 UTC (rev 16501)
@@ -79,6 +79,16 @@
 #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);

Modified: freeswitch/trunk/src/switch_core_session.c (16500 => 16501)


--- freeswitch/trunk/src/switch_core_session.c	2010-01-24 19:04:48 UTC (rev 16500)
+++ freeswitch/trunk/src/switch_core_session.c	2010-01-24 19:23:58 UTC (rev 16501)
@@ -1143,10 +1143,7 @@
 
 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)