X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FIn2Tie.pm;h=ffe26a44ab3d9e38d46447fd69543e0a9d4e5c8d;hb=af0b0fb7a454470a32c452119d0392e0dedb3fe1;hp=db1dc1045c14b52480ba5189d589593d76137a02;hpb=34c1a6c16733adee3acfe5861096692f3ea55378;p=public-inbox.git diff --git a/lib/PublicInbox/In2Tie.pm b/lib/PublicInbox/In2Tie.pm index db1dc104..ffe26a44 100644 --- a/lib/PublicInbox/In2Tie.pm +++ b/lib/PublicInbox/In2Tie.pm @@ -1,10 +1,23 @@ -# Copyright (C) 2020 all contributors +# Copyright (C) 2020-2021 all contributors # License: AGPL-3.0+ # used to ensure PublicInbox::DS can call fileno() as a function # on Linux::Inotify2 objects package PublicInbox::In2Tie; use strict; +use Symbol qw(gensym); + +sub io { + my $in2 = $_[0]; + $in2->blocking(0); + if ($in2->can('on_overflow')) { + # broadcasts everything on overflow + $in2->on_overflow(undef); + } + my $io = gensym; + tie *$io, __PACKAGE__, $in2; + $io; +} sub TIEHANDLE { my ($class, $in2) = @_;