From f7481bc0fa8eeb0291ad504744a612b7c7cf20e9 Mon Sep 17 00:00:00 2001 From: Elijah Perrault Date: Wed, 2 Feb 2011 20:49:19 -0700 Subject: [PATCH] Rewrote the socket engine. This should fix random timeouts. --- bin/auto | 26 ++++++++++++++++++-------- doc/CHANGELOG | 1 + 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/bin/auto b/bin/auto index ccde2a3..bf919d6 100755 --- a/bin/auto +++ b/bin/auto @@ -324,20 +324,30 @@ while (1) { $sockid = $_ if ($SOCKET{$_} eq $sock); } # Read the data. - my $data = readline($sock); - if (!defined $data) { + my $idata; + recv($sock, $idata, POSIX::BUFSIZ, 0); + + # Check for the data. + if (!defined $idata || length($idata) == 0) { # Got EOF, close socket err(2, "Lost connection to $sockid!", 0); $SELECT->remove($sock); next; } - # Remove the newlines. - chomp $data; - # Debug. - dbug $sockid." >> ".$data; - # Parse data. - Parser::IRC::ircparse($sockid, $data); + # Read the buffer. + my $data .= $idata; + while ($data =~ s/(.*\n)//) { + my $line = $1; + + # Remove the newlines. + chomp $line; + # Debug. + dbug $sockid." >> ".$line; + + # Parse data. + Parser::IRC::ircparse($sockid, $line); + } } } diff --git a/doc/CHANGELOG b/doc/CHANGELOG index de88fb6..490cdbe 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev ================================================================== + * Rewrote the socket engine. This should fix random timeouts. * Added IsItUp module. * Added user:net for network-specific user blocks. * Bug fix: Fixed broken no-parameter config blocks.