Subject: | Loosing initial pings for the same host when Parallelism > 1 |
Loosing of pings in the initial phase occurs when special conditions are
meet:
* Pings are send to the same host
* Parallelism is more or equal to 2 for POE::Component::Client::Ping
* Al least 2 ping events are created in a row (initial pings)
The number of lost pings: min( Parallelism, initial pings ) - 1.
The attachment demonstrates the issue.
Subject: | ping.pl |
#!/usr/bin/env perl
use strict;
use warnings;
use POE qw( Component::Client::Ping );
POE::Component::Client::Ping->spawn( Parallelism => 3 );
POE::Session->create(
inline_states => {
_start => sub {
$_[HEAP]->{hosts} = [ '127.0.0.1', '127.0.0.1', '127.0.0.1', '127.0.0.1', '127.0.0.1' ];
$_[KERNEL]->yield( 'ping' ) for (1..3);
},
_stop => sub {
print $_[HEAP]->{ok}, "\n";
},
ping => sub {
$_[KERNEL]->post( 'pinger', 'ping', 'pong', $_ ) if $_ = shift @{ $_[HEAP]->{hosts} };
},
pong => sub {
$_[HEAP]->{ok}++ if defined $_[ARG1]->[0];
$_[KERNEL]->yield( 'ping' );
},
},
);
POE::Kernel->run;
# Loosing of pings in the initial phase occurs when special conditions are meet:
#
# * Pings are send to the same host
# * Parallelism is more or equal to 2 for POE::Component::Client::Ping
# * Al least 2 ping events are created in a row (initial pings)
#
# The number of lost pings: min( Parallelism, initial pings ) - 1.