Re: DAST: Multicast Beacon - Configuring a central server - raul.fernandez --at-- mci.com


> Another fix was mailed to the list by someone else?

That would be me, I think.  I didn't prepare it as a patch (I will
do that when I return from a two-day travel starting in, um, 10
minutes...), but the gist is to replace

  # As long as there's data pending on the connection
  while (@ready = $select->can_read(1)) {
      foreach $fh (@ready) {
          if($fh == $server) {
                # Create a new socket
              $newsock = $server->accept;


              $select->add($newsock);
          }
          else {
              @lines = ();

              if (eof($fh)) {
                  $select->remove($fh);
                  close($fh);
                  next;
              } 
              while (defined ($line = <$fh>) && ($line ne $ENDMESSAGE)) {
                  push(@lines, $line);
              }

    # "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)) {

with

    # 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



Other Mailing lists | Author Index | Date Index | Subject Index | Thread Index