projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
moan about and then delete empty message files
[spider.git]
/
perl
/
DXMsg.pm
diff --git
a/perl/DXMsg.pm
b/perl/DXMsg.pm
index 65577607be6d30635f2053e417df6b98b3de7fa0..879775f3596f9f08bb9afa0f1ffb605100412938 100644
(file)
--- a/
perl/DXMsg.pm
+++ b/
perl/DXMsg.pm
@@
-136,7
+136,7
@@
sub process
# this is periodic processing
if (!$self || !$line) {
# this is periodic processing
if (!$self || !$line) {
- if ($main::systime > $lastq + $queueinterval) {
+ if ($main::systime >
=
$lastq + $queueinterval) {
# wander down the work queue stopping any messages that have timed out
for (keys %busy) {
# wander down the work queue stopping any messages that have timed out
for (keys %busy) {
@@
-512,6
+512,11
@@
sub read_msg_header
}
$size = -s $fn;
$line = <$file>; # first line
}
$size = -s $fn;
$line = <$file>; # first line
+ if ($size == 0 || !$line) {
+ dbg('err', "Empty $fn $!");
+ Log('err', "Empty $fn $!");
+ return undef;
+ }
chomp $line;
$size -= length $line;
if (! $line =~ /^===/o) {
chomp $line;
$size -= length $line;
if (! $line =~ /^===/o) {
@@
-616,7
+621,7
@@
sub queue_msg
next if $ref->{'read'}; # if it is read, it is stuck here
$clref = DXCluster->get_exact($ref->{to});
unless ($clref) { # otherwise look for a homenode
next if $ref->{'read'}; # if it is read, it is stuck here
$clref = DXCluster->get_exact($ref->{to});
unless ($clref) { # otherwise look for a homenode
- my $uref = DXUser->get($ref->{to});
+ my $uref = DXUser->get
_current
($ref->{to});
my $hnode = $uref->homenode if $uref;
$clref = DXCluster->get_exact($hnode) if $hnode;
}
my $hnode = $uref->homenode if $uref;
$clref = DXCluster->get_exact($hnode) if $hnode;
}
@@
-758,7
+763,12
@@
sub init
next unless /^m\d+$/o;
$ref = read_msg_header("$msgdir/$_");
next unless /^m\d+$/o;
$ref = read_msg_header("$msgdir/$_");
- next unless $ref;
+ unless ($ref) {
+ dbg('err', "Deleting $_");
+ Log('err', "Deleting $_");
+ unlink "$msgdir/$_";
+ next;
+ }
# delete any messages to 'badmsg.pl' places
if (grep $ref->{to} eq $_, @badmsg) {
# delete any messages to 'badmsg.pl' places
if (grep $ref->{to} eq $_, @badmsg) {
@@
-1235,6
+1245,9
@@
sub AUTOLOAD
$name =~ s/.*:://o;
confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
$name =~ s/.*:://o;
confess "Non-existant field '$AUTOLOAD'" if !$valid{$name};
+ # this clever line of code creates a subroutine which takes over from autoload
+ # from OO Perl - Conway
+ *{$AUTOLOAD} = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}} ;
@_ ? $self->{$name} = shift : $self->{$name} ;
}
@_ ? $self->{$name} = shift : $self->{$name} ;
}