in reply to
Re: socket periodically loses data
in thread socket periodically loses data
Probably nobody cares, but this was the fix:
$buf='';
if($fh->sysread($buf,4096)>0) {
d(2);
$this=$Con{$fh};
$buf=$this->{_}.$buf;
$bn=$lbn=-1;
while(($bn=index($buf,"\n",$bn+1)) >= 0) {
$s=substr($buf,$lbn+1,$bn-$lbn);
#print DEBUG "doing <$2>\n" if $DEBUG;
${$Con{$fh}}{getline}($fh,$s);
last unless $Con{$fh}; # it's possible that the connection can b
+e deleted while there's still something in the buffer
$lbn=$bn;
}
d(3);
if($Con{$fh}) {
($this->{_})=substr($buf,$lbn+1);
if(length($this->{_}) > 10000) {
d(4);
${$Con{$fh}}{getline}($fh,$this->{_});
($this->{_})='';
}
}
} else {
d(5);
done($fh);
}