Hi,

>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

The following sequences can deal with the 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.use GetQueuedCompletionStatus with zero timeout, try to process I/O 
completion event first
  if it has some I/O completion event, then don't need to call 
WSAWaitForMultipleEvents
4.if it has not I/O completion event, then calling WSAWaitForMultipleEvents

It still has race condition:
1.the second WSARecv/WSASend operation has completed before calling GQCS
2.this completion event has been process by GQCS, but left the hEvent as 
signaled
3.the next time to call WSAWaitForMultipleEvents, it will success, but GQCS 
cannot
  get any completion event. But it don't lead to a logic error, it lead to do a
  unwanted GQCS call in the worst situation.

The last source code:
http://spserver.googlecode.com/files/libevent-1.4.4-iocp-1.zip 

A a echo_iocp.exe test program is also included. This program seen to work 
fine, 
it can easy to deal with 1000 simultaneous connections propriety.

I hope someone can try this code, any and all comments are appreciated. 

=====================================================================================

With this strategy, the following test cases are passed:
test_bufferevent_watermarks();
test_multiple();                 
test_persistent();            

The following test cases still fail, but it's enviroment problem, not buggy.

http_suite();    fail on http.c::name_from_addr , vc6 has't getnameinfo function
rpc_suite();     it seem so complex to complile, give up
rpc_test();      same as above
dns_suite();     cannot compile evdns.c, because vc6's winsock2.h is too old 

Best Regards,

Stephen Liu
                        


_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users

Reply via email to