]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: clobber recvmsg buffer on errors
authorEric Wong <e@80x24.org>
Mon, 18 Apr 2022 09:50:01 +0000 (09:50 +0000)
committerEric Wong <e@80x24.org>
Mon, 18 Apr 2022 21:53:45 +0000 (21:53 +0000)
It will be necessary when we drop the Inline::C requirement
since the pure Perl Linux syscall recvmsg implementation.

This likely would've caused errors for Socket::MsgHdr users
without Inline::C, but I haven't tested it since it's a rare
configuration.

lib/PublicInbox/LEI.pm
lib/PublicInbox/LeiSelfSocket.pm

index a7ddc21f4da0de7ea55448994d80f90ec96f4f81..9ab91714d0b8b725fdda3b92889b70574dce6b83 100644 (file)
@@ -1149,6 +1149,7 @@ sub event_step {
                if (scalar(@fds) == 1 && !defined($fds[0])) {
                        return if $! == EAGAIN;
                        die "recvmsg: $!" if $! != ECONNRESET;
                if (scalar(@fds) == 1 && !defined($fds[0])) {
                        return if $! == EAGAIN;
                        die "recvmsg: $!" if $! != ECONNRESET;
+                       $buf = '';
                        @fds = (); # for open loop below:
                }
                for (@fds) { open my $rfh, '+<&=', $_ }
                        @fds = (); # for open loop below:
                }
                for (@fds) { open my $rfh, '+<&=', $_ }
index dd64b6cfd491f4b4517a18a321c2cd0cf826a38d..860020cb9e683db18a93e7904ee8d43d0cac4f98 100644 (file)
@@ -29,6 +29,7 @@ sub event_step {
        if (scalar(@fds) == 1 && !defined($fds[0])) {
                return if $!{EAGAIN};
                die "recvmsg: $!" unless $!{ECONNRESET};
        if (scalar(@fds) == 1 && !defined($fds[0])) {
                return if $!{EAGAIN};
                die "recvmsg: $!" unless $!{ECONNRESET};
+               $buf = '';
        } else { # just in case open so perl can auto-close them:
                for (@fds) { open my $fh, '+<&=', $_ };
        }
        } else { # just in case open so perl can auto-close them:
                for (@fds) { open my $fh, '+<&=', $_ };
        }