AnyEvent-FDpasser
view release on metacpan or search on metacpan
Preserves blocking status
After a fork, the non-blocking status of a descriptor is preserved so if
you are doing a socketpair followed by a fork it is acceptable to set
the non-blocking status of both descriptors in the parent.
Also, the non-blocking status of a descriptor passed with this module is
preserved after it is passed so it is not necessary to reset nonblocking
status on descriptors.
There is a test (non_blocking_fhs.t) to verify this and some other
assumptions for any given system.
Passing passers
Passing a descriptor and then using this descriptor as an argument to
the existing_fh mode of this module to construct another passer is
supported.
There is a test (send_passer_over_passer.t) to verify this assumption
for any given system.
Descriptor table full
Even when the descriptor table fills up intermittently, no descriptors
being passed should be lost.
There is a test (full_descriptor_table.t) to verify this.
SEE ALSO
<The AnyEvent::FDpasser github repo>
This module gets its name from File::FDpasser which does roughly the
same thing as this module except this module provides a non-blocking
interface, buffers the sending and receiving of descriptors, doesn't
lose descriptors in the event of a full descriptor table, and doesn't
print un-silenceable messages to stderr from the XS code.
Socket::PassAccessRights is another module similar to File::FDpasser. It
supports BSD4.3 and BSD4.4 interfaces.
Sprocket::Util::FDpasser is an example of a non-blocking interface to
File::FDpasser. It is based on POE whereas this module is (obviously)
based on AnyEvent.
A related module is Socket::MsgHdr which provides complete control over
ancillary data construction and parsing and is therefore useful for more
than just passing descriptors. However, this module does not provide a
non-blocking interface or buffering, and only supports the BSD4.4
interface (so it doesn't work for passing descriptors on Solaris).
BUGS
This module doesn't support windows. Theoretically windows support could
be added with some annoying combination of "DuplicateHandle" and
"WSADuplicateSocket" but I don't care enough to implement it at this
time.
If there are multiple outstanding filehandles to be sent, for
performance reasons this module could (on BSD4.4 systems) batch them
together into one "cmsg" and then execute one "sendmsg()" system call.
Unfortunately, that would make the close-dup trick less efficient. Maybe
there is a sweet spot?
It would be nice to auto-detect the best interface (BSD4.4/BSD4.3/SysV)
to use for a given system.
AUTHOR
Doug Hoyte, "<doug@hcsw.org>"
COPYRIGHT & LICENSE
Copyright 2012 Doug Hoyte.
This module is licensed under the same terms as perl itself.
( run in 2.659 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )