Permalink
Browse files

ignore SIGWINCH until we can get safe signals

add preliminary Win32 support... needs work
  • Loading branch information...
1 parent c935027 commit 497780d4bde17b8449bc8c431b5a7d971846e932 @rcaputo rcaputo committed Feb 3, 1999
Showing with 33 additions and 13 deletions.
  1. +25 −5 lib/POE/Kernel.pm
  2. +8 −8 samples/proxy.perl
View
@@ -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;
@@ -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') {
@@ -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
View
@@ -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,
@@ -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};
@@ -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};
@@ -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,
@@ -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};

0 comments on commit 497780d

Please sign in to comment.