From 938d734988bd99db66968698360a2a1a08f18025 Mon Sep 17 00:00:00 2001 From: Zoffix Znet Date: Thu, 31 Dec 2015 13:23:17 -0500 Subject: Fix freeze up on broken messages --- lib/IRC/Client.pm6 | 14 +++++++++----- lib/IRC/Grammar/Actions.pm6 | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/IRC/Client.pm6 b/lib/IRC/Client.pm6 index e130174..8c0b2c1 100644 --- a/lib/IRC/Client.pm6 +++ b/lib/IRC/Client.pm6 @@ -24,13 +24,17 @@ class IRC::Client:ver<2.001001> { await IO::Socket::Async.connect( $!host, $!port ).then({ $!sock = .result; $.ssay("NICK $!nick\n"); - $.ssay("USER $!username $!userhost $!host :$!userreal\n"); - $.ssay("JOIN $_\n") for @!channels; + $.ssay("USER $!username $!username $!host :$!userreal\n"); + $.ssay("JOIN {@!channels[]} x\n"); .irc-connected: self for @!plugs.grep(*.^can: 'irc-connected'); + # my $left-overs = ''; react { - whenever $!sock.Supply -> $str is copy { + whenever $!sock.Supply :bin -> $buf is copy { + my $str = try $buf.decode: 'utf8'; + $str or $str = $buf.decode: 'latin-1'; + # $str ~= $left-overs; $!debug and "[server {DateTime.now}] {$str}".put; my $events = parse-irc $str; EVENTS: for @$events -> $e { @@ -80,7 +84,7 @@ class IRC::Client:ver<2.001001> { say "Closing connection"; $!sock.close; - CATCH { warn .backtrace } + # CATCH { warn .backtrace } }); } @@ -91,7 +95,7 @@ class IRC::Client:ver<2.001001> { } method privmsg (Str $who, Str $what) { - my $msg = ":$!nick!$!username\@$!userhost PRIVMSG $who :$what\n"; + my $msg = "PRIVMSG $who :$what\n"; $!debug and "{plug-name}$msg".put; $!sock.print("$msg\n"); self; diff --git a/lib/IRC/Grammar/Actions.pm6 b/lib/IRC/Grammar/Actions.pm6 index 469f8f8..e7f5292 100644 --- a/lib/IRC/Grammar/Actions.pm6 +++ b/lib/IRC/Grammar/Actions.pm6 @@ -10,7 +10,8 @@ method message ($/) { %args = ~$pref if $pref.defined; my $p = $/; - loop { + + for ^100 { # bail out after 100 iterations; we're stuck if ( $p.defined ) { %args.append: ~$p; } -- cgit v1.1