summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2020-01-25 16:31:41 +0000
committerdakkar <dakkar@thenautilus.net>2020-01-25 16:31:41 +0000
commitaac983c95d33f2fa86b909e9e0f7ff3b47f5d7b5 (patch)
tree6adf4a75a55cf843db80794314a08cee4fe82e5e
parentRevert "fewer temporary variables" (diff)
downloadMaildirIndexer-aac983c95d33f2fa86b909e9e0f7ff3b47f5d7b5.tar.gz
MaildirIndexer-aac983c95d33f2fa86b909e9e0f7ff3b47f5d7b5.tar.bz2
MaildirIndexer-aac983c95d33f2fa86b909e9e0f7ff3b47f5d7b5.zip
timeout when parsing a socket
if the socket doesn't send an email message, we would be stuck waiting for it to do so since a socket is not a pipe, we can't detect "the other end has finished talking" ☹
-rw-r--r--lib/MaildirIndexer/Parser.rakumod3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/MaildirIndexer/Parser.rakumod b/lib/MaildirIndexer/Parser.rakumod
index d30ca86..c92fa22 100644
--- a/lib/MaildirIndexer/Parser.rakumod
+++ b/lib/MaildirIndexer/Parser.rakumod
@@ -86,7 +86,7 @@ multi parse-email(IO::Path:D $p, :$headers-only! --> MaildirIndexer::Email) is e
return $result;
}
-multi parse-email(IO::Socket::Async:D $s --> MaildirIndexer::Email) is export {
+multi parse-email(IO::Socket::Async:D $s, Int $timeout = 1 --> MaildirIndexer::Email) is export {
my MaildirIndexer::Email $result;
MaildirIndexer::LogTimelineSchema::Parse::Email::Socket.log: -> {
my $string;
@@ -99,6 +99,7 @@ multi parse-email(IO::Socket::Async:D $s --> MaildirIndexer::Email) is export {
$result = parse-email($string) and done;
QUIT { done };
}
+ whenever Promise.in($timeout) { done }
}
}
return $result;