diff --git a/lib/arch/CArchMultithreadPosix.cpp b/lib/arch/CArchMultithreadPosix.cpp index 304440b2..20a2ad47 100644 --- a/lib/arch/CArchMultithreadPosix.cpp +++ b/lib/arch/CArchMultithreadPosix.cpp @@ -40,6 +40,7 @@ public: public: int m_refCount; + IArchMultithread::ThreadID m_id; pthread_t m_thread; IArchMultithread::ThreadFunc m_func; void* m_userData; @@ -51,6 +52,7 @@ public: CArchThreadImpl::CArchThreadImpl() : m_refCount(1), + m_id(0), m_func(NULL), m_userData(NULL), m_cancel(false), @@ -69,7 +71,8 @@ CArchThreadImpl::CArchThreadImpl() : CArchMultithreadPosix* CArchMultithreadPosix::s_instance = NULL; CArchMultithreadPosix::CArchMultithreadPosix() : - m_newThreadCalled(false) + m_newThreadCalled(false), + m_nextID(0) { assert(s_instance == NULL); @@ -505,6 +508,7 @@ bool CArchMultithreadPosix::waitForEvent(double /*timeout*/) { // not implemented + return false; } bool @@ -534,7 +538,7 @@ CArchMultithreadPosix::getResultOfThread(CArchThread thread) IArchMultithread::ThreadID CArchMultithreadPosix::getIDOfThread(CArchThread thread) { - return reinterpret_cast(reinterpret_cast(thread)); + return thread->m_id; } void @@ -601,6 +605,12 @@ CArchMultithreadPosix::insert(CArchThreadImpl* thread) // thread shouldn't already be on the list assert(findNoRef(thread->m_thread) == NULL); + // set thread id. note that we don't worry about m_nextID + // wrapping back to 0 and duplicating thread ID's since the + // likelihood of synergy running that long is vanishingly + // small. + thread->m_id = ++m_nextID; + // append to list m_threadList.push_back(thread); } diff --git a/lib/arch/CArchMultithreadPosix.h b/lib/arch/CArchMultithreadPosix.h index 59d14155..07e2f1d9 100644 --- a/lib/arch/CArchMultithreadPosix.h +++ b/lib/arch/CArchMultithreadPosix.h @@ -87,6 +87,7 @@ private: CArchMutex m_threadMutex; CArchThread m_mainThread; CThreadList m_threadList; + ThreadID m_nextID; pthread_t m_signalThread; }; diff --git a/lib/arch/CArchNetworkBSD.cpp b/lib/arch/CArchNetworkBSD.cpp index 8e3f4706..474c68fc 100644 --- a/lib/arch/CArchNetworkBSD.cpp +++ b/lib/arch/CArchNetworkBSD.cpp @@ -641,8 +641,9 @@ CArchNetworkBSD::addrToName(CArchNetAddress addr) // mutexed name lookup (ugh) ARCH->lockMutex(m_mutex); - struct hostent* info = gethostbyaddr(&addr->m_addr, addr->m_len, - addr->m_addr.sa_family); + struct hostent* info = gethostbyaddr( + reinterpret_cast(&addr->m_addr), + addr->m_len, addr->m_addr.sa_family); if (info == NULL) { ARCH->unlockMutex(m_mutex); throwNameError(h_errno);