[Libevent-users] Integrate Windows I/O Completion Port into
Libevent
liusifan
liusifan at gmail.com
Wed Jun 4 09:30:55 EDT 2008
Hi,
>>3. How to integrate these two mechanism ?
>>When we issue a WSARecv or WSASend, we need to pass a OVERLAPPED structure. This structure has a hEvent member.
>>We could use one event for all WSARecv/WSASend.
http://msdn.microsoft.com/en-us/library/ms686358(VS.85).aspx
Synchronization and Overlapped Input and Output
If an event is used, the hEvent member of the OVERLAPPED structure specifies a
handle to the allocated event object. The system sets the state of the event object
to nonsignaled when a call to the I/O function returns before the operation has been completed.
The integrate strategy for IOCP and WSAEventSelect is not safe.
Because WSARecv/WSASend will sets the state of the event object to nonsignaled.
This can lead to a race condition:
1.the first WSARecv/WSASend operations have completed, hEvent is signaled
2.the second WSARecv/WSASend has been called, hEvent has been reseted
3.WSAWaitForMultipleEvents will block until the second operations have completed
It need to try other way to integrate IOCP and WSAEventSelect.
Best Regards,
Stephen Liu
More information about the Libevent-users
mailing list