Navigation Menu

Skip to content

Commit

Permalink
ignore SIGWINCH until we can get safe signals
Browse files Browse the repository at this point in the history
add preliminary Win32 support... needs work
  • Loading branch information
rcaputo committed Feb 3, 1999
1 parent c935027 commit 497780d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
30 changes: 25 additions & 5 deletions lib/POE/Kernel.pm
Expand Up @@ -26,18 +26,23 @@ BEGIN {
}

#------------------------------------------------------------------------------
# Redirect STDERR to STDOUT, and kill all the buffering. Used
# internally for testing; it should be commented out.

# BEGIN {
# open(STDERR, '>&STDOUT') or die $!;
# select(STDERR); $| = 1;
# select(STDOUT); $| = 1;
# }

#------------------------------------------------------------------------------
# Redefine __WARN__ and __DIE__ to be in different colors, so they
# stand out. Do a caller() stack trace when something dies. Used
# internally for testing; it should be commented out.

# BEGIN {
# package DB;
# if ($^O eq 'os2') {
# close STDERR; open(STDERR, '>&STDOUT');
# select(STDERR); $| = 1; select(STDOUT); $| = 1;
# $SIG{'__WARN__'} =
# sub { my $msg = join(' ', @_);
# $msg =~ s/[\x0d\x0a]+//g;
Expand Down Expand Up @@ -273,7 +278,21 @@ sub new {
|
)$/x
);
if (($signal eq 'CHLD') || ($signal eq 'CLD')) {

# Artur has been experiencing problems where POE programs crash
# after resizing xterm windows. It was discovered that the
# xterm resizing was sending several WINCH signals, which
# eventually causes Perl to become unstable. Ignoring SIGWINCH
# seems to prevent the problem, but it's only a temporary
# solution. At some point, POE will include a set of Curses
# widgets, and SIGWINCH will be needed...

if ($signal eq 'WINCH') {
$SIG{$signal} = 'IGNORE';
next;
}
# register signal handlers by type
if ($signal =~ /^CH?LD$/) {
$SIG{$signal} = \&_signal_handler_child;
}
elsif ($signal eq 'PIPE') {
Expand Down Expand Up @@ -942,9 +961,10 @@ sub _internal_select {
binmode($handle);
# set the handle non-blocking
# do it the Win32 way
if ($^O eq '"MSWin32') {
if ($^O eq 'MSWin32') {
my $set_it = "1";
ioctl($handle, 126, $set_it)
# 126 is FIONBIO
ioctl($handle, 126 | (ord('f')<<8) | (4<<16) | 0x80000000, $set_it)
or croak "Can't set the handle non-blocking: $!\n";
}
# do it the way everyone else does
Expand Down
16 changes: 8 additions & 8 deletions samples/proxy.perl
Expand Up @@ -63,10 +63,10 @@ sub session_start {
my ($heap, $socket, $peer_host, $peer_port, $remote_addr, $remote_port) =
@_[HEAP, ARG0, ARG1, ARG2, ARG3, ARG4];

$heap->{log} = ++$log_id;
$heap->{'log'} = ++$log_id;

$peer_host = inet_ntoa($peer_host);
print "[$heap->{log}] Accepted connection from $peer_host:$peer_port\n";
print "[$heap->{'log'}] Accepted connection from $peer_host:$peer_port\n";

$heap->{wheel_client} = new POE::Wheel::ReadWrite
( Handle => $socket,
Expand All @@ -93,7 +93,7 @@ sub session_start {
sub session_stop {
my $heap = $_[HEAP];

print "[$heap->{log}] Closing redirection session\n";
print "[$heap->{'log'}] Closing redirection session\n";

delete $heap->{wheel_client};
delete $heap->{wheel_server};
Expand All @@ -114,12 +114,12 @@ sub session_client_error {
my ($heap, $operation, $errnum, $errstr) = @_[HEAP, ARG0, ARG1, ARG2];

if ($errnum) {
print( "[$heap->{log}] Client connection encountered ",
print( "[$heap->{'log'}] Client connection encountered ",
"$operation error $errnum: $errstr\n"
);
}
else {
print "[$heap->{log}] Client closed connection.\n";
print "[$heap->{'log'}] Client closed connection.\n";
}
# stop the wheels
delete $heap->{wheel_client};
Expand All @@ -133,7 +133,7 @@ sub session_client_error {
sub session_server_connect {
my ($heap, $socket) = @_[HEAP, ARG0];

print "[$heap->{log}] Successfully connected to remote server.\n";
print "[$heap->{'log'}] Successfully connected to remote server.\n";

$heap->{wheel_server} = new POE::Wheel::ReadWrite
( Handle => $socket,
Expand All @@ -159,12 +159,12 @@ sub session_server_error {
my ($heap, $operation, $errnum, $errstr) = @_[HEAP, ARG0, ARG1, ARG2];

if ($errnum) {
print( "[$heap->{log}] Server connection encountered ",
print( "[$heap->{'log'}] Server connection encountered ",
"$operation error $errnum: $errstr\n"
);
}
else {
print "[$heap->{log}] Server closed connection.\n";
print "[$heap->{'log'}] Server closed connection.\n";
}
# stop the wheels
delete $heap->{wheel_client};
Expand Down

0 comments on commit 497780d

Please sign in to comment.