AnyEvent-FDpasser

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    different.

TESTS AND SYSTEM ASSUMPTIONS
    All the following tests should work with BSD4.4, BSD4.3, and SysV
    interfaces (where available).

  Bidirectional
    A passer is bidirectional and can be used to both send and receive
    descriptors, even simultaneously.

    There are tests (basic_socketpair.t and basic_filesystem.t) to verify
    this.

  Non-blocking
    A process may initiate push_recv_fh on a passer and this process will
    not block while it is waiting for the other end to call push_send_fh
    (and vice versa).

    There are tests (recv_before_send.t and send_before_recv.t) to verify
    this.

  FIFO ordering
    The order descriptors are sent with push_send_fh is the same order that
    they are received on at the other end with push_recv_fh.

    There is a test (buffer_exercise.t) to verify this and some other basic
    buffering properties.

  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.

README.pod  view on Meta::CPAN


=head1 TESTS AND SYSTEM ASSUMPTIONS

All the following tests should work with BSD4.4, BSD4.3, and SysV interfaces (where available).


=head2 Bidirectional

A passer is bidirectional and can be used to both send and receive descriptors, even simultaneously.

There are tests (basic_socketpair.t and basic_filesystem.t) to verify this.


=head2 Non-blocking

A process may initiate push_recv_fh on a passer and this process will not block while it is waiting for the other end to call push_send_fh (and vice versa).

There are tests (recv_before_send.t and send_before_recv.t) to verify this.


=head2 FIFO ordering

The order descriptors are sent with push_send_fh is the same order that they are received on at the other end with push_recv_fh.

There is a test (buffer_exercise.t) to verify this and some other basic buffering properties.


=head2 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.


=head2 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.


=head2 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.






=head1 SEE ALSO

L<The AnyEvent::FDpasser github repo|https://github.com/hoytech/AnyEvent-FDpasser>

lib/AnyEvent/FDpasser.pm  view on Meta::CPAN


=head1 TESTS AND SYSTEM ASSUMPTIONS

All the following tests should work with BSD4.4, BSD4.3, and SysV interfaces (where available).


=head2 Bidirectional

A passer is bidirectional and can be used to both send and receive descriptors, even simultaneously.

There are tests (basic_socketpair.t and basic_filesystem.t) to verify this.


=head2 Non-blocking

A process may initiate push_recv_fh on a passer and this process will not block while it is waiting for the other end to call push_send_fh (and vice versa).

There are tests (recv_before_send.t and send_before_recv.t) to verify this.


=head2 FIFO ordering

The order descriptors are sent with push_send_fh is the same order that they are received on at the other end with push_recv_fh.

There is a test (buffer_exercise.t) to verify this and some other basic buffering properties.


=head2 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.


=head2 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.


=head2 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.






=head1 SEE ALSO

L<The AnyEvent::FDpasser github repo|https://github.com/hoytech/AnyEvent-FDpasser>

t/basic_filesystem.t  view on Meta::CPAN

use common::sense;

use AnyEvent::Strict;
use AnyEvent::FDpasser;

use Test::More tests => 2;


## The point of this test is to verify that fdpasser_server and fdpasser_connect can
## create sockets suitable for use with FDpasser.


my $path = '/tmp/fdpasser_junk_socket';

my $done_cv = AE::cv;


if (fork) {
  my $server_fh = AnyEvent::FDpasser::fdpasser_server($path);

t/basic_socketpair.t  view on Meta::CPAN

use common::sense;

use AnyEvent::Strict;
use AnyEvent::FDpasser;

use Test::More tests => 2;


## The point of this test is to create a socketpair, fork, and then
## verify that the $passer object can be used to send and receive
## descriptors.


my $passer = AnyEvent::FDpasser->new( fh => [ AnyEvent::FDpasser::fdpasser_socketpair ] );

my $done_cv = AE::cv;


if (fork) {
  $passer->i_am_parent;

t/full_descriptor_table.t  view on Meta::CPAN

eval { require BSD::Resource };

if (!$@) {
  plan tests => 1;
} else {
  plan skip_all => 'Install BSD::Resource to run this test';
}


## The point of this test is to exercise the full file descriptor code 
## and verify that no descriptors are lost.



my $passer = AnyEvent::FDpasser->new;

my $done_cv = AE::cv;


if (fork) {
  $passer->i_am_parent;

t/recv_before_send.t  view on Meta::CPAN

use common::sense;

use Time::HiRes;

use AnyEvent::Strict;
use AnyEvent::FDpasser;

use Test::More tests => 3;


## The point of this test is to verify that push_recv_fh can be called before
## there is any fh waiting to be received and the process will not block.

## WARNING: this test relied on timers and is not fully deterministic



my $passer = AnyEvent::FDpasser->new;

my $done_cv = AE::cv;

t/send_before_recv.t  view on Meta::CPAN

use common::sense;

use Time::HiRes;

use AnyEvent::Strict;
use AnyEvent::FDpasser;

use Test::More tests => 2;


## The point of this test is to verify that push_send_fh can be called before
## there is any process on the other end calling push_recv_fh and the process
## will not block.

## WARNING: this test relied on timers and is not fully deterministic



my $passer = AnyEvent::FDpasser->new;

my $done_cv = AE::cv;

t/send_passer_over_passer.t  view on Meta::CPAN

use common::sense;

use AnyEvent::Strict;
use AnyEvent::FDpasser;
use AnyEvent::Util;

use Test::More tests => 1;


## The point of this somewhat esoteric test is to verify that you can
## send passer sockets (AF_UNIX sockets) themselves over a passer object.

## To do this, we setup a passer object between a parent and child,
## create a socketpair in the parent, and then send this socket to the
## child over the passer object. The parent and children both use their
## respective ends of the socketpair to instantiate another passer object
## over which a pipe is sent.





( run in 0.412 second using v1.01-cache-2.11-cpan-5467b0d2c73 )