Re: Thread deadlock misery
"PaulH" <paul.heil@gmail.com> wrote in message
news:1173805200.294745.94950@q40g2000cwq.googlegroups.com...
I use the AtlCreateThread() call to create the thread. That's why it's
declared that way. If you still think it's wrong, let me know.
static DWORD WINAPI TransmitThread( TTCB* TFP );
m_hTransmitThread = AtlCreateThread( TransmitThread, pTFP );
From ATLBASE.H:
template <typename T>
HANDLE AtlCreateThread(DWORD (WINAPI* pfn)(T *pparam), T *pparam)
{
return CreateThreadT(0, 0, pfn, pparam, 0, 0);
}
template <typename T>
HANDLE CreateThreadT(LPSECURITY_ATTRIBUTES lpsa, DWORD dwStackSize,
DWORD (WINAPI * pfn)(T *pparam),
T *pparam, DWORD dwCreationFlags, LPDWORD pdw)
{
return DefaultThreadTraits::CreateThread(lpsa,
dwStackSize,
(LPTHREAD_START_ROUTINE)pfn,
Yes, this is evil. Don't use it. The only thing you can do with a cast of
a function pointer is cast it back, but CreateThread is going to call it.
pparam,
dwCreationFlags,
pdw);
}
This is the only thread I have that uses the WSA API, so I found it
convenient to put the WSAStartup() and WSACleanup() calls in here.
Ok, good enough. I assumed the corresponding receive thread also used
sockets.
BOOL m_bRunning does need to be volatile, thank you.
Why is sizeof(SOCKADDR) meaningless? DUTAddr->ai_addr is a SOCKADDR*.
The parameter wants to know what size the address pointer is. What do
you recommend I use?
SOCKADDR is assumed to be an incomplete type. The actual buffer will be a
sockaddr_in or sockaddr_in6 or sockaddr_unix or etc.
I think you and alexander may have hit on my problem: dwSleepTime will
never be 0... I'm going to investigate that issue now.