]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/TLS.pm
tls: epollbit: account for miscellaneous OpenSSL errors
[public-inbox.git] / lib / PublicInbox / TLS.pm
1 # Copyright (C) 2019-2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 # IO::Socket::SSL support code
5 package PublicInbox::TLS;
6 use strict;
7 use IO::Socket::SSL;
8 use PublicInbox::Syscall qw(EPOLLIN EPOLLOUT);
9 use Carp qw(carp);
10
11 sub err () { $SSL_ERROR }
12
13 # returns the EPOLL event bit which matches the existing SSL error
14 sub epollbit () {
15         return EPOLLIN if $SSL_ERROR == SSL_WANT_READ;
16         return EPOLLOUT if $SSL_ERROR == SSL_WANT_WRITE;
17         carp "unexpected SSL error: $SSL_ERROR";
18         undef;
19 }
20
21 1;