user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 11/11] replace ParentPipe with EOFpipe
Date: Mon, 31 Aug 2020 04:41:40 +0000	[thread overview]
Message-ID: <20200831044140.17027-12-e@80x24.org> (raw)
In-Reply-To: <20200831044140.17027-1-e@80x24.org>

ParentPipe was a subset of EOFpipe, except EOFpipe correctly
accounts for theoretical(*) spurious wakeups on the pipe.

(*) AFAIK, spurious wakeups are/were more likely on TCP sockets
    due to checksum failures, something that's not a problem on
    local pipes.  We're also not sharing pipes like we do with
    listen sockets on accept(2), so there's no chance of another
    process grabbing bytes (unless we have bugs in our code).
---
 MANIFEST                      |  1 -
 lib/PublicInbox/Daemon.pm     |  6 ++----
 lib/PublicInbox/ParentPipe.pm | 23 -----------------------
 3 files changed, 2 insertions(+), 28 deletions(-)
 delete mode 100644 lib/PublicInbox/ParentPipe.pm

diff --git a/MANIFEST b/MANIFEST
index 0b3835d8..b65e96b0 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -169,7 +169,6 @@ lib/PublicInbox/NNTPdeflate.pm
 lib/PublicInbox/NewsWWW.pm
 lib/PublicInbox/Over.pm
 lib/PublicInbox/OverIdx.pm
-lib/PublicInbox/ParentPipe.pm
 lib/PublicInbox/ProcessPipe.pm
 lib/PublicInbox/Qspawn.pm
 lib/PublicInbox/Reply.pm
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index 45475183..000ba169 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -17,7 +17,7 @@ STDERR->autoflush(1);
 use PublicInbox::DS qw(now);
 use PublicInbox::Syscall qw($SFD_NONBLOCK);
 require PublicInbox::Listener;
-require PublicInbox::ParentPipe;
+use PublicInbox::EOFpipe;
 use PublicInbox::Sigfd;
 my @CMD;
 my ($set_user, $oldset);
@@ -468,8 +468,6 @@ sub master_quit ($) {
 
 sub master_loop {
 	pipe(my ($p0, $p1)) or die "failed to create parent-pipe: $!";
-	# 1031: F_SETPIPE_SZ, 4096: page size
-	fcntl($p1, 1031, 4096) if $^O eq 'linux';
 	my $set_workers = $worker_processes;
 	reopen_logs();
 	my $ignore_winch;
@@ -603,7 +601,7 @@ sub daemon_loop ($$$$) {
 	if ($worker_processes > 0) {
 		$refresh->(); # preload by default
 		my $fh = master_loop(); # returns if in child process
-		PublicInbox::ParentPipe->new($fh, \&worker_quit);
+		PublicInbox::EOFpipe->new($fh, \&worker_quit, undef);
 	} else {
 		reopen_logs();
 		$set_user->() if $set_user;
diff --git a/lib/PublicInbox/ParentPipe.pm b/lib/PublicInbox/ParentPipe.pm
deleted file mode 100644
index 538b5632..00000000
--- a/lib/PublicInbox/ParentPipe.pm
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
-# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-
-# only for PublicInbox::Daemon, allows worker processes to be
-# notified if the master process dies.
-package PublicInbox::ParentPipe;
-use strict;
-use parent qw(PublicInbox::DS);
-use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT);
-
-sub new ($$$) {
-	my ($class, $pipe, $worker_quit) = @_;
-	my $self = bless { cb => $worker_quit }, $class;
-	$self->SUPER::new($pipe, EPOLLIN|EPOLLONESHOT);
-}
-
-# master process died, time to call worker_quit ourselves
-sub event_step {
-	$_[0]->close; # PublicInbox::DS::close
-	$_[0]->{cb}->();
-}
-
-1;

      parent reply	other threads:[~2020-08-31  4:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31  4:41 [PATCH 00/11] watch: fix contention w/ Maildir & NNTP Eric Wong
2020-08-31  4:41 ` [PATCH 01/11] watch: limit batch size of NNTP and IMAP workers, too Eric Wong
2020-08-31  4:41 ` [PATCH 02/11] watchmaildir: use v5.10.1, drop warnings Eric Wong
2020-08-31  4:41 ` [PATCH 03/11] rename WatchMaildir => Watch Eric Wong
2020-08-31  4:41 ` [PATCH 04/11] watch: log signal activities to STDERR Eric Wong
2020-08-31  4:41 ` [PATCH 05/11] watch: avoid unnecessary spawning on spam removals Eric Wong
2020-08-31  4:41 ` [PATCH 06/11] watch: block signals before fork on non-signalfd/kevent systems Eric Wong
2020-08-31  4:41 ` [PATCH 07/11] watch: comments and tiny cleanups Eric Wong
2020-08-31  4:41 ` [PATCH 08/11] ds: avoid excessive queueing when reaping PIDs Eric Wong
2020-08-31  4:41 ` [PATCH 09/11] watch: use EOFpipe to reduce dwaitpid wakeups Eric Wong
2020-08-31  4:41 ` [PATCH 10/11] ds: avoid unnecessary timer for waitpid Eric Wong
2020-08-31  4:41 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200831044140.17027-12-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).