X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FMsg.pm;h=1099ba8804f881106e918c699798a3b233810868;hb=ba49813ff2ce03b9b92c16810f74afeae10c28ca;hp=02795812e40bc5da3445953b0e56e382ff46ef27;hpb=6616898c4373267522bcacca20e58157bd5a538b;p=spider.git diff --git a/perl/Msg.pm b/perl/Msg.pm index 02795812..1099ba88 100644 --- a/perl/Msg.pm +++ b/perl/Msg.pm @@ -47,6 +47,7 @@ sub new my $conn = { rproc => $rproc, inqueue => [], + outqueue => [], state => 0, lineend => "\r\n", csort => 'telnet', @@ -118,7 +119,7 @@ sub _send { my ($conn, $flush) = @_; my $sock = $conn->{sock}; return unless defined($sock); - my ($rq) = $conn->{outqueue}; + my $rq = $conn->{outqueue}; # If $flush is set, set the socket to blocking, and send all # messages in the queue - return only if there's an error @@ -244,8 +245,12 @@ sub _rcv { # Complement to _send if ($bytes_read > 0) { if ($msg =~ /\n/) { @lines = split /\r?\n/, $msg; - $lines[0] = $conn->{msg} . $lines[0] if exists $conn->{msg}; - push @lines, ' ' unless @lines; + if (@lines) { + $lines[0] = $conn->{msg} . $lines[0] if exists $conn->{msg}; + } else { + $lines[0] = $conn->{msg} if exists $conn->{msg}; + push @lines, '' unless @lines; + } if ($msg =~ /\n$/) { delete $conn->{msg}; } else {