add some extra info around connects for tracking connections
[spider.git] / perl / ExtMsg.pm
index d8e660b8fea045d23d865214b3a1528543291f52..8a5e4612926b9b5da6a8212f6404090f62c78fab 100644 (file)
@@ -129,6 +129,7 @@ sub new_client {
                $conn->{blocking} = 0;
                
                my ($rproc, $eproc) = &{$server_conn->{rproc}} ($conn, $conn->{peerhost} = $sock->peerhost(), $conn->{peerport} = $sock->peerport());
+               dbg('connll', "accept $conn->{cnum} from $conn->{peerhost} $conn->{peerport}");
                if ($eproc) {
                        $conn->{eproc} = $eproc;
                        Msg::set_event_handler ($sock, "error" => $eproc);
@@ -318,8 +319,10 @@ sub _dochat
                                return;
                        }
                        if ($line =~ /\Q$expect/i) {
-                               dbg('connect', "got: \"$expect\" sending: \"$send\"");
-                               $conn->send_later("D$conn->{call}|$send");
+                               if (length $send) {
+                                       dbg('connect', "got: \"$expect\" sending: \"$send\"");
+                                       $conn->send_later("D$conn->{call}|$send");
+                               }
                                delete $conn->{msg}; # get rid any input if a match
                                return;
                        }
@@ -333,8 +336,6 @@ sub _timedout
 {
        my $conn = shift;
        dbg('connect', "timed out after $conn->{timeval} seconds");
-       $conn->{timeout}->del;
-       delete $conn->{timeout};
        $conn->disconnect;
 }
 
@@ -363,8 +364,9 @@ sub _send_file
                if ($f) {
                        while (<$f>) {
                                chomp;
-                               dbg('connll', $_);
-                               $conn->send_raw($_ . $conn->{lineend});
+                               my $l = $_;
+                               dbg('connll', "connect $conn->{cnum}: $l");
+                               $conn->send_raw($l . $conn->{lineend});
                        }
                        $f->close;
                }