1. Crossed fingers, got rid of the instabilities caused by execing programs
[spider.git] / perl / DXChannel.pm
index 7319344caeb51fa8bda7770f5c12f397f685e7c6..5505610e9752b8520f6270733fdc0b1387185bc0 100644 (file)
@@ -156,12 +156,11 @@ sub send_now
        my $conn = $self->{conn};
        my $sort = shift;
        my $call = $self->{call};
-       my $line;
        
-       foreach $line (@_) {
-               chomp $line;
-               $conn->send_now("$sort$call|$line") if $conn;
-               dbg('chan', "-> $sort $call $line") if $conn;
+       for (@_) {
+               chomp;
+               $conn->send_now("$sort$call|$_") if $conn;
+               dbg('chan', "-> $sort $call $_") if $conn;
        }
        $self->{t} = time;
 }
@@ -174,12 +173,11 @@ sub send                                          # this is always later and always data
        my $self = shift;
        my $conn = $self->{conn};
        my $call = $self->{call};
-       my $line;
 
-       foreach $line (@_) {
-               chomp $line;
-               $conn->send_later("D$call|$line") if $conn;
-               dbg('chan', "-> D $call $line") if $conn;
+       for (@_) {
+               chomp;
+               $conn->send_later("D$call|$_") if $conn;
+               dbg('chan', "-> D $call $_") if $conn;
        }
        $self->{t} = time;
 }
@@ -212,6 +210,7 @@ sub state
        if (@_) {
                $self->{oldstate} = $self->{state};
                $self->{state} = shift;
+               $self->{func} = '' unless defined $self->{func};
                dbg('state', "$self->{call} channel func $self->{func} state $self->{oldstate} -> $self->{state}\n");
        }
        return $self->{state};
@@ -232,6 +231,22 @@ sub disconnect
        $self->del();
 }
 
+#
+# just close all the socket connections down without any fiddling about, cleaning, being
+# nice to other processes and otherwise telling them what is going on.
+#
+# This is for the benefit of forked processes to prepare for starting new programs, they
+# don't want or need all this baggage.
+#
+
+sub closeall
+{
+       my $ref;
+       foreach $ref (values %channels) {
+               $ref->{conn}->disconnect() if $ref->{conn};
+       }
+}
+
 # various access routines
 
 #