# additional subprocesses, they just deal with the message setting at their
# queue, and then process the next message as it comes in.
+$SIG{'ALRM'} = 'IGNORE';
$SIG{'CHLD'} = \&chld_handler;
if( $upd_pid = fork() ) {
# Read all from the client, and disconnect, we process the message next.
- my $header = <CLIENT>; chomp $header;
+ my( $header, $ok ) = ( "", 0 );
my( $message, $cnt, $line ) = ( "", "", "" );
- while( defined( $line = <CLIENT> ) ) {
- last if ($cnt += length($line)) > 100000;
- $message .= $line;
- }
+
+ # Set an alarm on this block in case the client runs into problems
+ eval
+ {
+ local $SIG{'ALRM'} = sub { die; };
+ alarm($SPONG_SERVER_ALARM) if $SPONG_SERVER_ALARM;
+
+ $header = <CLIENT>; chomp $header;
+ while( defined( $line = <CLIENT> ) ) {
+ last if ($cnt += length($line)) > 100000;
+ $message .= $line;
+ }
+
+ $ok = 1;
+ };
+ alarm(0);
close( CLIENT );
+ if ( ! $ok ) {
+ &error( "ss_update: Connection from $paddr timed out" );
+ next;
+ }
+
# Now depending on what kind of message it is, pass it off to a routine
# that can process the message. Currently valid messages are "status",
# "ack", "config", and "stat".