Re: Trying to get beacon 1.1-0 working
- To: mitch@ncsa.uiuc.edu
- Subject: Re: Trying to get beacon 1.1-0 working
- From: Havard Eidnes <he@uninett.no>
- Date: Thu, 01 Sep 2005 17:33:58 +0200 (CEST)
- Cc: beacon@dast.nlanr.net
- Content-transfer-encoding: 8bit
- Content-type: Text/Plain; charset=iso-8859-1
- In-reply-to: <3.0.5.32.20050830173808.01e24198@pop.ncsa.uiuc.edu>
- References: <20050825.224151.38061437.he@uninett.no> <3.0.5.32.20050830173808.01e24198@pop.ncsa.uiuc.edu>
- Reply-to: Havard Eidnes <he@uninett.no>
- Sender: owner-beacon@dast.nlanr.net
Hi, Mitch,
> We're looking into this now. We'll keep you posted on what we
> find out, and if/when we have a patch available.
>
> Thanks for your report!
I now think I have more proper fix for this problem, and the good
news is that it is a server-side-only fix. The start of my
receive_tcp_report() function (again, based on 1.1-0 sources) now
looks like this:
# As long as there's data pending on the connection
while (@ready = $select->can_read(1)) {
NEXTFH:
foreach $fh (@ready) {
if($fh == $server) {
# Create a new socket
$newsock = $server->accept;
$select->add($newsock);
}
else {
if (eof($fh)) {
undef(@{$lines{$fh}});
$select->remove($fh);
close($fh);
next;
}
while(defined($line = <$fh>) && ($line ne $ENDMESSAGE)) {
if (!defined($lines{$fh})) {
@{$lines{$fh}} = ();
}
push(@{$lines{$fh}}, $line);
}
if (!defined($line)) {
if ($DEBUG>4) {
printf("Incomplete message, %d lines collected\n",
scalar(@{$lines{$fh}}));
}
next NEXTFH; # incomplete message, collect more later
}
# Here we have $line eq $ENDMESSAGE, i.e. a complete message
# has been collected, so proceed to process it
@lines = @{$lines{$fh}};
undef(@{$lines{$fh}});
if ($DEBUG>4) {
printf("Processing %d lines\n", scalar(@lines));
}
# "scalar(@lines) is just the length of @lines -- Ie,
# loop for all lines in the array.
my $ii=0; # Simple linecounter for receiving report
while ($ii < scalar(@lines)) {
Additionally, you need a global declaration of the %lines hash.
Regards,
- Håvard