Re: Multithread safety



Nathan Evans wrote:
> I find this quite shocking.
>
> So you are saying that when you've got several threads on a completion
> port all posting WSARecv's on the same socket (potentially at the same
> instant in time) that there is a race condition?

Practically most likely not. What you do with WSARecv in such case is to
post a *request* to read not to perform an actual reading operation. The
reads themselves *presumably* will be serialized. According to MSDN docs on
CreateIoCompletionPort

<quote>
The I/O completion port places the completion packet in a first-in-first-out
queue.
</quote>

which I interpret as a sort of a promise that reads will be serialized.

However, posting multiple reads from different threads is still a bad idea.
Why would you want to do this?


--
Eugene
http://www.gershnik.com


.


Loading