CVS update: /common/netio/, /common/netio/pub/
bobclark at helixcommunity.org bobclark at helixcommunity.orgUser: bobclark Date: 03/01/28 15:01:17 Modified /common/netio/ thrdconn.cpp /common/netio/pub/ thrdconn.h Log updated so Carbon implementation never has the rug pulled out from under itself File Changes: Directory: /common/netio/ ========================= File [changed]: thrdconn.cpp Url: https://common.helixcommunity.org/source/browse/common/netio/thrdconn.cpp.diff?r1=1.1.1.1&r2=1.2 Delta lines: +35 -11 --------------------- --- thrdconn.cpp 18 Oct 2002 01:44:40 -0000 1.1.1.1 +++ thrdconn.cpp 28 Jan 2003 23:01:17 -0000 1.2 @@ -48,6 +48,10 @@ #include "platform/unix/UnixThreads.h" #endif /* _UNIX_THREADED_NETWORK_IO */ +#ifdef _CARBON +#include "carbthrd.h" +#endif + #include "hxslist.h" #include "growingq.h" @@ -139,8 +143,7 @@ pEngine->AttachSocket(this); m_pNetworkThread = pEngine->GetNetworkThread(); m_pMainAppThread = pEngine->GetMainAppThread(); - m_pNetCallback = new ThrConnSocketCallback; - m_pNetCallback->m_pContext = this; + m_pNetCallback = new ThrConnSocketCallback(this); #if defined(THREADS_SUPPORTED) || defined(_UNIX_THREADED_NETWORK_IO) HXMutex::MakeMutex(m_pMutex); @@ -231,8 +234,16 @@ } } m_pMainAppThread=NULL; +#elif defined(_CARBON) && defined(THREADS_SUPPORTED) + // remove any messages from the main app thread for us. + HX_ASSERT(m_pMainAppThread); + HXThreadMessage msgBack; + HXThreadMessage msgMatch(0, (void*)this, NULL, NULL); + while (((HXCarbonThread*)m_pMainAppThread)->PeekMessageMatching(&msgBack, &msgMatch, TRUE) == HXR_OK) + { + } + m_pMainAppThread = NULL; #endif - } ULONG32 ThreadedConn::AddRef() @@ -1268,6 +1279,9 @@ void ThreadedConn::DoRead(BOOL bFromReadNotification) { +#ifdef _CARBON + AddRef(); // ensure that this object doesn't encounter its dtor before routine completes +#endif HX_RESULT theErr = HXR_OK; m_pMutex->Lock(); @@ -1392,11 +1406,17 @@ exit: m_pMutex->Unlock(); +#ifdef _CARBON + Release(); +#endif } void ThreadedConn::DoWrite() { +#ifdef _CARBON + AddRef(); +#endif HX_RESULT theErr = HXR_OK; m_pMutex->Lock(); if (m_uSocketType == HX_TCP_SOCKET) @@ -1490,6 +1510,9 @@ m_bConnected = FALSE; PostDoneAndDetach(); } +#ifdef _CARBON + Release(); +#endif } void @@ -1560,26 +1583,27 @@ void ThreadedConn::ThrConnSocketCallback::Func(NotificationType Type, BOOL bSuccess, conn* pConn) { - if(m_pContext) + ThreadedConn* pContext = m_pContext; + if(pContext) { switch (Type) { case READ_NOTIFICATION: - m_pContext->DoRead(TRUE); + pContext->DoRead(TRUE); break; case WRITE_NOTIFICATION: - m_pContext->DoWrite(); + pContext->DoWrite(); break; case CONNECT_NOTIFICATION: - m_pContext->HandleConnectNotification(bSuccess); + pContext->HandleConnectNotification(bSuccess); break; case DNS_NOTIFICATION: - m_pContext->HandleDNSNotification(bSuccess); + pContext->HandleDNSNotification(bSuccess); break; case ACCEPT_NOTIFICATION: - m_pContext->HandleAcceptNotification(pConn); + pContext->HandleAcceptNotification(pConn); case CLOSE_NOTIFICATION: - m_pContext->HandleCloseNotification(); + pContext->HandleCloseNotification(); break; default: break; Directory: /common/netio/pub/ ============================= File [changed]: thrdconn.h Url: https://common.helixcommunity.org/source/browse/common/netio/pub/thrdconn.h.diff?r1=1.1.1.1&r2=1.2 Delta lines: +1 -0 ------------------- --- thrdconn.h 18 Oct 2002 01:44:40 -0000 1.1.1.1 +++ thrdconn.h 28 Jan 2003 23:01:17 -0000 1.2 @@ -232,6 +232,7 @@ public: void Func(NotificationType Type, BOOL bSuccess = TRUE, conn* pConn = NULL); ThreadedConn* m_pContext; + ThrConnSocketCallback(ThreadedConn* pContext = NULL) : m_pContext(pContext) {} }; friend class ThrConnSocketCallback; --------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe at common.helixcommunity.org For additional commands, e-mail: cvs-help at common.helixcommunity.org