Skip to content

Commit

Permalink
0.1007 is in the can
Browse files Browse the repository at this point in the history
  • Loading branch information
rcaputo committed Jun 8, 2000
1 parent b79f2dc commit de98f39
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 26 deletions.
40 changes: 30 additions & 10 deletions Changes
Expand Up @@ -16,15 +16,11 @@ subversions are available from <http://www.newts.org/~troc/poe.html>.

,----- To Do -----
|
| Next
|
| Event doesn't seem very fast; am I using it incorrectly?
|
| Before 0.11
|
| Test $kernel->fork()
| Test $kernel->fork() or replace it entirely.
|
| Turn SocketFactory's sample program into a test case.
| Test SocketFactory with UDP sockets.
|
| After 0.11
|
Expand All @@ -34,9 +30,33 @@ subversions are available from <http://www.newts.org/~troc/poe.html>.
`-----------------


0.1006 2000.??.?? (!!!)
0.1007 2000.06.07
-----------------

Version 0.1006 was put on the web site, but ignatz found a bug in
SocketFactory that prevented t/09_wheels_unix.t from passing on
Linux machines. a-mused confirmed that the problem appears on Linux
but not Solaris. My own FreeBSD system was not affected. The bug
relates to calling getpeername on UNIX domain sockets. The resulting
unpack_sockaddr_un call would fail when getpeername returned an
undefined (not undef) value. The failing code is now wrapped in
eval, and it will gracefully recover from this sort of error.

Many thanks to ignatz and a-mused for quick testing, and to Fletch
for verifying that 0.1007 works on RedHat 6.2 x86!


0.1006 2000.06.07 (!!!)
-----------------------

This version was placed on the web site, but a-mused and ignatz found
bugs SocketFactory right away. As a result, I held off announcing it
to the mailing list until a fix could be included.

Added t/12_signals_ev.t to test Event's SIGCHLD handler. It's pretty
much the same as t/11_signals_poe.t, but using Event or skipping itself
if Event is not available.

Increased the time that t/11_signals_poe.t waits to reap children. On
memory- and cpu-challenged systems, swap times could delay process
exits, causing false failures when the test program timed out.
Expand All @@ -49,9 +69,9 @@ greatly reduces the amount of work done in POE's stock $SIG{CHLD}
handlers which in turn reduces the probability that SIGCHLD will
segfault Perl. Note, however, that the chance of this occurring will
remain nonzero as long as Perl is not signal safe. (Also, the patch
wouldn't apply and I sort of redid the code as I spliced the idea into
the Kernel. It's probably busted, and I should compare it against
Philip's original patch to make sure it works the way he intended.)
wouldn't apply and I sort of redid the code as I spliced it into the
the Kernel. I'll know when Philip tests it whether I've broken his
algorithm.)

Tweaked postbacks. Older Perl versions were not doing the right
things with \@_ in POE::Session's postback() method. Replaced it
Expand Down
2 changes: 1 addition & 1 deletion lib/POE.pm
Expand Up @@ -7,7 +7,7 @@ use strict;
use Carp;

use vars qw($VERSION);
$VERSION = 0.1006;
$VERSION = 0.1007;

sub import {
my $self = shift;
Expand Down
4 changes: 0 additions & 4 deletions lib/POE/Kernel.pm
Expand Up @@ -1571,8 +1571,6 @@ sub _tk_select_callback {
sub _event_fifo_callback {
my $self = $poe_kernel;

warn "fifo callback";

{% dispatch_one_from_fifo %}

# Stop the idle watcher if there are no more state transitions in
Expand Down Expand Up @@ -1653,8 +1651,6 @@ sub _invoke_state {

if ($state eq EN_SCPOLL) {

warn $state;

# Non-blocking wait for a child process. If one was reaped,
# dispatch a SIGCHLD to the session who called fork.

Expand Down
22 changes: 19 additions & 3 deletions lib/POE/Wheel/SocketFactory.pm
Expand Up @@ -153,9 +153,23 @@ sub _define_connect_state {
my $peer = getpeername($handle);
my ($peer_addr, $peer_port);

# getpeername's return value in undefined for unbound peer
# sockets in the Unix domain. Take precautions against
# evil undefined behavior.

if ($domain eq DOM_UNIX) {
$peer_addr = unpack_sockaddr_un($peer);
$peer_port = undef;
$peer_addr = $peer_port = undef;
if (defined $peer) {
eval {
$peer_addr = unpack_sockaddr_un($peer);
};
if ($@) {
$peer_addr = undef;
}
}
else {
$peer_addr = undef;
}
}
elsif ($domain eq DOM_INET) {
($peer_port, $peer_addr) = unpack_sockaddr_in($peer);
Expand Down Expand Up @@ -895,7 +909,9 @@ For INET sockets, ARG1 and ARG2 hold the socket's remote address and
port, respectively.
For Unix client sockets, ARG1 contains the server address and ARG2 is
undefined.
undefined. Some systems have trouble getting the address of a socket's
remote end, so ARG1 may be undefined if there was trouble determining
it.
According to _Perl Cookbook_, the remote address for accepted Unix
domain sockets is undefined. So ARG0 and ARG1 are, too.
Expand Down
4 changes: 4 additions & 0 deletions mylib/coverage.perl
Expand Up @@ -29,6 +29,8 @@

# Run each test with coverage statistics.

goto SPANG;

foreach my $test_file (@test_files) {
unlink "$test_file.coverage";

Expand All @@ -40,6 +42,8 @@
}
}

SPANG:

# Combine coverage statistics across all files.

foreach my $test_file (@test_files) {
Expand Down
4 changes: 2 additions & 2 deletions tests/09_wheels_unix.t
Expand Up @@ -93,7 +93,7 @@ sub server_unix_start {
unlink $unix_server_socket if -e $unix_server_socket;

$heap->{wheel} = POE::Wheel::SocketFactory->new
( SocketDomain => AF_UNIX,
( SocketDomain => PF_UNIX,
BindAddress => $unix_server_socket,
SuccessState => 'got_client',
FailureState => 'got_error',
Expand Down Expand Up @@ -141,7 +141,7 @@ sub client_unix_start {
my $heap = $_[HEAP];

$heap->{wheel} = POE::Wheel::SocketFactory->new
( SocketDomain => AF_UNIX,
( SocketDomain => PF_UNIX,
RemoteAddress => $unix_server_socket,
SuccessState => 'got_server',
FailureState => 'got_error',
Expand Down
7 changes: 1 addition & 6 deletions tests/12_signals_ev.t
Expand Up @@ -18,7 +18,6 @@ BEGIN {

# Turn on all asserts.
sub POE::Kernel::ASSERT_DEFAULT () { 1 }
sub POE::Kernel::TRACE_DEFAULT () { 1 }
use POE;

&test_setup(2);
Expand All @@ -34,7 +33,7 @@ eval {
import Time::HiRes qw(time sleep);
};

my $fork_count = 1;
my $fork_count = 16;

# Set up a signal catching session. This test uses plain fork(2) and
# POE's $SIG{CHLD} handler.
Expand All @@ -58,7 +57,6 @@ POE::Session->create
}
else {
sleep $wake_time - time();
warn "child $$ exits";
dump;
}
}
Expand All @@ -79,7 +77,6 @@ warn "child $$ exits";

_stop =>
sub {
warn "stop";
my $heap = $_[HEAP];
if ($heap->{reaped} == $fork_count) {
print "ok 2\n";
Expand All @@ -91,14 +88,12 @@ warn "child $$ exits";

catch_sigchld =>
sub {
warn "sigchld";
$_[HEAP]->{reaped}++;
$_[KERNEL]->delay( time_is_up => 15 );
},

time_is_up =>
sub {
warn "time is up";
# do nothing, really
},
},
Expand Down

0 comments on commit de98f39

Please sign in to comment.