The post($sender, $event, ....) call sends $event response back to
your code if send() fails. The response address, round-trip time, and
TTL are undefined. The response time is "now".
You've added logging in a good place, if you want to solve this by
modifying the module. It might be better to catch the $event in your
application and log the problem there.
--
Rocco Caputo - [email protected]
On Apr 21, 2009, at 16:31, Stuart Kendrick wrote:
i'm walking through .../perl5/site_perl/5.10.0/POE/Component/Client/
Ping.pm
where do we emit an error if we are unable to send an ICMP packet?
seems to me that we decide to send the ping in the very last line of
'sub poco_ping_ping':
[...]
# Request a ping. This code borrows heavily from Net::Ping.
sub poco_ping_ping {
[...]
_send_packet($kernel, $heap);
}
and we actually send the ping on line 362, within the '_send_packet'
routine, specifically, from the 'send' phrase within the 'unless'
clause:
sub _send_packet {
my ($kernel, $heap) = @_;
return unless (scalar @{$heap->{queue}});
[...]
# Send the packet. If send() fails, then we bail with an error.
my @user_args = ();
($event, @user_args) = @$event if ref($event) eq "ARRAY";
DEBUG and warn "sending packet sequence number $seq\n";
unless (send($heap->{socket_handle}, $msg, ICMP_FLAGS,
$socket_address)) {
$kernel->post(
$sender, $event,
[ $address, # REQ_ADDRESS
$timeout, # REQ_TIMEOUT
time(), # REQ_TIME
@user_args, # REQ_USER_ARGS
],
[ undef, # RES_ADDRESS
undef, # RES_ROUNDTRIP
time(), # RES_TIME
undef, # RES_TTL
],
);
_check_for_close($kernel, $heap);
return;
}
[...]
now, i see the comment "If send() fails, then we bail with an
error". but i don't see where we actually spit out an error
message. seems to me that _send_packet returns with a value of 0
(that 'return' statement just after the call to
_check_for_close) ... but i don't see us checking the return value
of _send_packet, back in "sub poco_ping_ping"
or ... does the "$kernel-post( ..." event trigger an error message,
through some mechanism i don't understand?
would it be reasonable for me to add the following, in order to
track the success/failure of the call to send() ?
[...]
unless (send($heap->{socket_handle}, $msg, ICMP_FLAGS,
$socket_address)) {
warn "Unable to send() ICMP packet";
$kernel->post(
[...]
or would i be duplicating effort performed elsewhere?
actually, what i really want to do is to log such events to syslog,
so am i headed in a fruitful direction by adding the following?
[...]
unless (send($heap->{socket_handle}, $msg, ICMP_FLAGS,
$socket_address)) {
use Sys::Syslog;
openlog('PoCo-Ping', 'nofatal,ndelay,pid', 'local0');
syslog('error', 'Unable to send() ICMP packet');
closelog();
$kernel->post(
[...]
--sk