* [PATCH 8/9] ds: inline set_cloexec
2021-10-01 9:54 7% [PATCH 0/9] daemon-related things Eric Wong
@ 2021-10-01 9:54 6% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-10-01 9:54 UTC (permalink / raw)
To: meta
I'm thinking we can drop support for Linux <2.6.27 soonish and
just use EPOLL_CLOEXEC. Perl without signalfd (or
EVFILT_SIGNAL) is miserable, actually.
---
lib/PublicInbox/DS.pm | 46 ++++++++++++++++++-------------------------
1 file changed, 19 insertions(+), 27 deletions(-)
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index ba6c74d0ea97..debb777a27e8 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -44,7 +44,7 @@ my $ToClose; # sockets to close when event loop is done
our (
%DescriptorMap, # fd (num) -> PublicInbox::DS object
$Epoll, # Global epoll fd (or DSKQXS ref)
- $_io, # IO::Handle for Epoll
+ $ep_io, # IO::Handle for Epoll
$PostLoopCallback, # subref to call at the end of each loop, if defined (global)
@@ -78,7 +78,7 @@ sub Reset {
for my $q (@q) { @$q = () }
$EXPMAP = undef;
$wait_pids = $nextq = $ToClose = undef;
- $_io = undef; # closes real $Epoll FD
+ $ep_io = undef; # closes real $Epoll FD
$Epoll = undef; # may call DSKQXS::DESTROY
} while (@Timers || keys(%Stack) || $nextq || $wait_pids ||
$ToClose || keys(%DescriptorMap) ||
@@ -127,32 +127,24 @@ sub add_uniq_timer { # ($name, $secs, $coderef, @args) = @_;
$UniqTimer{$_[0]} //= _add_named_timer(@_);
}
-# keeping this around in case we support other FD types for now,
-# epoll_create1(EPOLL_CLOEXEC) requires Linux 2.6.27+...
-sub set_cloexec ($) {
- my ($fd) = @_;
-
- open($_io, '+<&=', $fd) or return;
- defined(my $fl = fcntl($_io, F_GETFD, 0)) or return;
- fcntl($_io, F_SETFD, $fl | FD_CLOEXEC);
-}
-
# caller sets return value to $Epoll
-sub _InitPoller
-{
- if (PublicInbox::Syscall::epoll_defined()) {
- my $fd = epoll_create();
- set_cloexec($fd) if (defined($fd) && $fd >= 0);
- $fd;
- } else {
- my $cls;
- for (qw(DSKQXS DSPoll)) {
- $cls = "PublicInbox::$_";
- last if eval "require $cls";
- }
- $cls->import(qw(epoll_ctl epoll_wait));
- $cls->new;
- }
+sub _InitPoller () {
+ if (PublicInbox::Syscall::epoll_defined()) {
+ my $fd = epoll_create();
+ die "epoll_create: $!" if $fd < 0;
+ open($ep_io, '+<&=', $fd) or return;
+ my $fl = fcntl($ep_io, F_GETFD, 0);
+ fcntl($ep_io, F_SETFD, $fl | FD_CLOEXEC);
+ $fd;
+ } else {
+ my $cls;
+ for (qw(DSKQXS DSPoll)) {
+ $cls = "PublicInbox::$_";
+ last if eval "require $cls";
+ }
+ $cls->import(qw(epoll_ctl epoll_wait));
+ $cls->new;
+ }
}
sub now () { clock_gettime(CLOCK_MONOTONIC) }
^ permalink raw reply related [relevance 6%]
* [PATCH 0/9] daemon-related things
@ 2021-10-01 9:54 7% Eric Wong
2021-10-01 9:54 6% ` [PATCH 8/9] ds: inline set_cloexec Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-10-01 9:54 UTC (permalink / raw)
To: meta
5/9 has been a long-time coming, a few other small things, too.
The diff stat for lib/ alone shows a nice reduction
Eric Wong (9):
doc: lei-security: some more updates
listener: switch to level-triggered epoll
daemon: make SO_ACCEPTFILTER a shared variable
ipc: run Net::SSLeay::randomize
ds: simplify signalfd use
inbox: inline and eliminate git_cleanup
inbox: keep DB handles if git processes are live
ds: inline set_cloexec
doc: lei-daemon: new manpage
Documentation/lei-daemon.pod | 61 ++++++++++++++++
Documentation/lei-security.pod | 5 +-
Documentation/lei.pod | 9 ++-
Documentation/lei_design_notes.txt | 2 +-
MANIFEST | 1 +
Makefile.PL | 2 +-
lib/PublicInbox/ConfigIter.pm | 2 +-
lib/PublicInbox/DS.pm | 110 ++++++++++++++---------------
lib/PublicInbox/DSKQXS.pm | 10 +--
lib/PublicInbox/Daemon.pm | 20 ++----
lib/PublicInbox/ExtMsg.pm | 2 +-
lib/PublicInbox/ExtSearchIdx.pm | 12 +---
lib/PublicInbox/Gcf2Client.pm | 4 +-
lib/PublicInbox/Git.pm | 4 +-
lib/PublicInbox/IPC.pm | 5 +-
lib/PublicInbox/Inbox.pm | 41 +++++------
lib/PublicInbox/LEI.pm | 17 +----
lib/PublicInbox/Listener.pm | 5 +-
lib/PublicInbox/Qspawn.pm | 2 +-
lib/PublicInbox/Sigfd.pm | 10 +--
lib/PublicInbox/Syscall.pm | 12 ++--
lib/PublicInbox/Watch.pm | 3 +-
script/public-inbox-watch | 9 ---
t/dir_idle.t | 6 +-
t/ds-leak.t | 4 +-
t/httpd-corner.t | 4 +-
t/httpd-https.t | 6 +-
t/httpd.t | 6 +-
t/imapd-tls.t | 7 +-
t/imapd.t | 6 +-
t/nntpd-tls.t | 7 +-
t/nntpd.t | 2 +-
t/sigfd.t | 7 +-
t/watch_maildir.t | 2 +-
xt/mem-imapd-tls.t | 6 +-
xt/net_writer-imap.t | 2 +-
36 files changed, 221 insertions(+), 192 deletions(-)
create mode 100644 Documentation/lei-daemon.pod
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-10-01 9:54 7% [PATCH 0/9] daemon-related things Eric Wong
2021-10-01 9:54 6% ` [PATCH 8/9] ds: inline set_cloexec Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).