[zeromq-dev] sendmsg atomicity /threads

Martin Sustrik sustrik at 250bpm.com
Tue Jan 5 15:00:52 CET 2010


Jon Dyte wrote:
> found this link
> 
> http://www.almaden.ibm.com/cs/people/marksmith/sendmsg.html
> 
> in short solaris 10 and aix are ok ( as far are author could tell), elsewhere 
> it all looks doomed....

AFAIK POSIX defines PIPE_BUF constant. If the data you send is less than
PIPE_BUF it is guaranteed to be atomic.

However, passing a socket through UNIX domain socket is done via
ancillary data rather than normal data, thus it is unclear whether it is
included in PIPE_BUF or not.

I would suppose it is not and socket passing can be used safely, but
it's hard to tell how it works on different OS platforms.

In any case I would suggest following the path discussed before: Open a
TCP connection, pass a unix domain socket from connecting app to binding
app (in form of a generated filename, INET domain sockets are not
capable of passing raw sockets AFAIK). Close the TCP socket, use the
pipe instead.

The biggest advantage of the approach above is that it's only a slight
modification of existing TCP transport rather than completely new
transport that would have to be implemented from scratch.

Still, keep in mind that pipe is unidirectional whereas TCP socket is
bidirectional. We'll have to create _two_ pipes to retain existing
functionality.

Martin





More information about the zeromq-dev mailing list