length word at the fron anymore).
added watchdbg (a cross between tail -f and grep)
+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
} else { # Uh, oh
delete $conn->{send_offset};
$conn->handle_send_err($!);
+ $conn->disconnect;
return 0; # fail. Message remains in queue ..
}
}
}
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){
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;
}
# 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) {
--- /dev/null
+#!/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);
} else
*mp->inp++ = *p;
}
- }
+ }
*mp->inp++ = '\n';
*mp->inp = 0;
cmsg_send(f->outq, mp, 0);
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;
}
case EAGAIN:
goto lend;
default:
- if (f->sort == MSG)
- send_Z = 0;
+/* if (f->sort == MSG)
+ send_Z = 0; */
ending++;
return;
}
if (in && in->t_set)
tcsetattr(0, TCSANOW, &in->t);
if (node) {
+ shutdown(node->cnum, 3);
close(node->cnum);
}
exit(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);
}
if (in && in->t_set)
tcsetattr(0, TCSADRAIN, &in->t);
- if (node)
+ if (node) {
+ shutdown(node->cnum, 3);
close(node->cnum);
+ }
exit(i);
}