[Mono-devel-list] PATCH: reworked async IO for Socket

James Mansion james at wgold.demon.co.uk
Wed Apr 13 01:42:13 EDT 2005


>The license of libevent allows doing that, but the code in
>WIN32-Code/win32.c is using select(), not IOCP. I prefer waiting for

select() in a Win32 application! FFS.  Let me guess, someone
with a UNIX background  wrote it, thinking that the wait event
call would otherwise limit to only 64 handles?

Hopefully it can be rescued without the surgery that a change
to an IOCP structure would mean:

* create an array of event objects, some convenient prime in
  size <64
* for each async IO request against a socket, hash it randomly
  across these event objects
* maintain a list of requests against each event where we
  contain the OVERLAPPED structures with their hEvent set to
  the associated event
* WaitForMultipleObjects return will tell you which request list
  to search
* check the completion status of each OVERLAPPED structure.

Alternatively use the completion routine facility and receive
notification by APCs.

But please, don't use Win32 select() except to port UNIXy
stuff.  Performance will suck, and some stupid fanboy will
use it to piss on Microsoft when the problem is in the app.

Personally, I'd abstract into a layer that looks much
more like IOCP and implement fakes on the *NIX side, and
hope that eventually somebody fixes the aio implementations
to make this trivial as it should be.  As an application
programmer, I want to know when the transfer I requested
is complete, not be pointlessly woken up every time there
is a possibility that *some* data *might* get sent if
I try again - I'd hope the OS could schedule some transfers
from the protocol manager rather than having to reschedule
threads all the time, too. Oh well.

James






More information about the Mono-devel-list mailing list