[zeromq-dev] IOCP

Martin Sustrik sustrik at 250bpm.com
Mon Aug 30 09:45:53 CEST 2010


Hi Kelly,

> 	I've plugged in an iocp_t poller and replaced select in the
> http://github.com/All8Up/zeromq2 fork, it is non-functional but does bring
> up the iocp and such without crashing.  I have to add the AcceptEx/ConnectEx
> functionality to get things working, but I'm out of time today.
>
> 	This is a VERY evil initial get something up and working attempt so
> please do not go looking at it for cleanliness/error checking etc at this
> time. :)

> 	Note: when I made the fork, there was an error in socket_base.cpp at
> approx line 162, it was checking for "ipc" protocol but the comparison was
> "!=" instead of "==", so bind always failed on Win32 if you "didn't" use an
> ipc protocol.  "local_lat" was failing with valid parameters on Win32.

Ok, I'll fix that.

What about the fix you've done in select.hpp?

>
> 	Currently I'm trying for as close as possible to the epoll version.
> This is not a great way for iocp to work but I figure with something up and
> functional we can work out how to push out better support later, though even
> the bad way is likely better than using a select loop.

Hopefully, you would be able to refine the work you do into actual 
requirements of what has to be changed in 0mq's poller infrastructure to 
make it work smoothly with IOCP.

> 	If you grab the code keep in mind the following:
>
> 1.	The send code won't work as written, a zero byte send is a nop, just
> did that for a placeholder.  My intention is to change it to a
> "PostQueuedCompletionStatus" to initialize the send in the worker thread.
> Unfortunately that will require some way to associate the send in the
> socket_base with an OVERLAPPED structure which currently I have in the
> poller code right now.
>
> 2.	Both accept and connect will need to be completely different in the
> base sockets.  And you have to query for the functions via GUID, total
> lameness but standard Win32 crap.
>
> 3.	I've posted the code only because others are interested and I'm not
> going to get back to it till sometime tomorrow.  Please take it as intended,
> just a quick see what we can get up and working without any major changes
> first, then work out the best way to push out changes which are compatible
> with everything and allow IOCP to actually be fast.
>
> 	Also note: I posted up a quick premake4.lua if you want to use it.
> I'm just using it for a little testbed and it's not 100% correct.  I know
> *nix folks prefer autoconf and all that, I just like being able to build IDE
> projects for debugging purposes mostly because I'm spoiled anymore.. :)
>
>> Go to http://github.com/zeromq/zeromq2 and click of 'fork' button.
>>
>> You'll have to use git then which may be pain in the ass at first if you
>> are not familiar with it, but it _really_ is a better collaboration tool
>> than SVN.
>
> 	I'm perfectly willing to use git or anything else, not picky as long
> as it works.  Made the branch above and muddled through commiting the
> relevant iocp starting point tests.  Hopefully I didn't screw anything up..
> :)

It looks OK.

Martin



More information about the zeromq-dev mailing list