]> dxcluster.net Git - spider.git/commitdiff
made the communications between clients and server completely ascii (no
authordjk <djk>
Thu, 11 May 2000 16:00:30 +0000 (16:00 +0000)
committerdjk <djk>
Thu, 11 May 2000 16:00:30 +0000 (16:00 +0000)
length word at the fron anymore).
added watchdbg (a cross between tail -f and grep)

Changes
perl/Msg.pm
perl/cluster.pl
perl/watchdbg [new file with mode: 0755]
src/client.c

diff --git a/Changes b/Changes
index acc45f675692d70f236afa21f6765a2f2f7b5ac6..979873b7c51b3c586f3b6ff361ba64ec97d6597f 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,8 @@
+11May00=======================================================================
+1. fixed looping in Msg.pm (at last)
+10May00=======================================================================
+1. wrote a cross between 'tail -f' and grepdbg so that you can watch the
+debug files for particular strings and only have them print out. 
 05May00=======================================================================
 1. rewrote parts of Msg.pm and client.c so that the messages no longer use
 a length word at the front of each one. They are simply strings of characters
index d067f27e31c35ee2fec876577a345eb2fb7a274b..b626e27c67958eb9822f12491298d349094c31c4 100644 (file)
@@ -128,6 +128,7 @@ sub _send {
                 } else {    # Uh, oh
                                        delete $conn->{send_offset};
                     $conn->handle_send_err($!);
+                                       $conn->disconnect;
                     return 0; # fail. Message remains in queue ..
                 }
             }
@@ -231,9 +232,10 @@ sub _rcv {                     # Complement to _send
     }
 
 FINISH:
-    if (defined $bytes_read == 0) {
-               $conn->disconnect();
+    if (defined $bytes_read && $bytes_read == 0) {
+#              $conn->disconnect();
                &{$conn->{rcvd_notification_proc}}($conn, undef, $!);
+               @lines = ();
     } 
 
        while (@lines){
index 3ea1d6a52025fa1bb3ee65d975f61e3de6bbd96d..54295e4b7beaaec871a50d39187319f5ffd6aeaf 100755 (executable)
@@ -103,9 +103,11 @@ sub rec
        my ($conn, $msg, $err) = @_;
        my $dxchan = DXChannel->get_by_cnum($conn); # get the dxconnnect object for this message
        
-       if (defined $err && $err) {
+       if (!defined $msg || (defined $err && $err)) {
                if ($dxchan) {
                        $dxchan->disconnect;
+               } elsif ($conn) {
+                       $conn->disconnect;
                }
                return;
        }
@@ -369,11 +371,17 @@ dbg('local', "Local::init error $@") if $@;
 # this, such as it is, is the main loop!
 print "orft we jolly well go ...\n";
 dbg('chan', "DXSpider version $version started...");
+
+open(DB::OUT, "|tee /tmp/aa");
+
 for (;;) {
        my $timenow;
+       $DB::trace = 1;
+       
        Msg->event_loop(1, 0.1);
        $timenow = time;
        process_inqueue();                      # read in lines from the input queue and despatch them
+       $DB::trace = 0;
        
        # do timed stuff, ongoing processing happens one a second
        if ($timenow != $systime) {
diff --git a/perl/watchdbg b/perl/watchdbg
new file mode 100755 (executable)
index 0000000..745d698
--- /dev/null
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+#
+# watch the end of the current debug file (like tail -f) applying
+# any regexes supplied on the command line.
+#
+# examples:-
+# 
+#   watchdbg g1tlh       # watch everything g1tlh does
+#   watchdbg gb7baa gb7djk   # watch the conversation between BAA and DJK 
+#
+
+require 5.004;
+
+# search local then perl directories
+BEGIN {
+       # root of directory tree for this system
+       $root = "/spider"; 
+       $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
+       
+       unshift @INC, "$root/perl";     # this IS the right way round!
+       unshift @INC, "$root/local";
+}
+
+use IO::File;
+use DXVars;
+use DXUtil;
+use DXLog;
+
+use strict;
+
+my $fp = DXLog::new('debug', 'dat', 'd');
+my @today = Julian::unixtoj(time()); 
+my $fh = $fp->open(@today) or die $!; 
+my $exp = join '|', @ARGV;
+
+# seek to end of file
+$fh->seek(0, 2);
+for (;;) {
+       my $line = <$fh>;
+       if ($line) {
+               if ($exp) {
+                       printit($line) if $line =~ m{(?:$exp)}oi;
+               } else {
+            printit($line);
+        }
+       } else {
+               sleep(1);
+
+               # check that the debug hasn't rolled over to next day
+               # open it if it has
+               my @now = Julian::unixtoj(time()); 
+               if ($today[1] != $now[1]) {
+                       $fp->close;
+                       $fh = $fp->open(@now) or die $!; 
+               }
+       }
+}
+
+sub printit
+{
+       my $line = shift;
+       my @line =  split '\^', $line;
+       my $t = shift @line;
+       print atime($t), ' ', join('^', @line); 
+}
+exit(0);
index 22e06f6976505fdebac7b3fa31db1e739d95519e..1f899c58dcf29ea589f4ce42526fbab8959693cc 100644 (file)
@@ -264,7 +264,7 @@ void send_msg(fcb_t *f, char let, unsigned char *s, int l)
                        } else 
                                *mp->inp++ = *p;
                }
-       }
+       } 
        *mp->inp++ = '\n';
        *mp->inp = 0;
        cmsg_send(f->outq, mp, 0);
@@ -295,14 +295,14 @@ int fcb_handler(sel_t *sp, int in, int out, int err)
                        case EAGAIN:
                                goto lout;
                        default:
-                               if (f->sort == MSG)
-                                       send_Z = 0;
+/*                             if (f->sort == MSG)
+                               send_Z = 0; */
                                ending++;
                                return 0;
                        }
                } else if (r == 0) {
-                       if (f->sort == MSG)
-                               send_Z = 0;
+/*                     if (f->sort == MSG)
+                       send_Z = 0; */
                        ending++;
                        return 0;
                }
@@ -473,8 +473,8 @@ lout:;
                                case EAGAIN:
                                        goto lend;
                                default:
-                                       if (f->sort == MSG)
-                                               send_Z = 0;
+/*                                     if (f->sort == MSG)
+                                       send_Z = 0; */
                                        ending++;
                                        return;
                                }
@@ -597,6 +597,7 @@ void term_timeout(int i)
        if (in && in->t_set)
                tcsetattr(0, TCSANOW, &in->t);
        if (node) {
+               shutdown(node->cnum, 3);
                close(node->cnum);
        }
        exit(i);
@@ -605,7 +606,7 @@ void term_timeout(int i)
 void terminate(int i)
 {
        if (node && send_Z && call) {
-               send_msg(node, 'Z', "", 0);
+               send_msg(node, 'Z', "bye", 3);
        }
        
        signal(SIGALRM, term_timeout);
@@ -617,8 +618,10 @@ void terminate(int i)
        }
        if (in && in->t_set)
                tcsetattr(0, TCSADRAIN, &in->t);
-       if (node) 
+       if (node) {
+               shutdown(node->cnum, 3);
                close(node->cnum);
+       }
        exit(i);
 }