From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/7] ipc: some documentation comments
Date: Sun, 3 Jan 2021 02:06:11 +0000 [thread overview]
Message-ID: <20210103020617.15719-2-e@80x24.org> (raw)
In-Reply-To: <20210103020617.15719-1-e@80x24.org>
Fix some comments and add some short summary descriptions to
hopefully make things easier-to-follow.
---
lib/PublicInbox/IPC.pm | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm
index 288a8c94..79cd34fe 100644
--- a/lib/PublicInbox/IPC.pm
+++ b/lib/PublicInbox/IPC.pm
@@ -10,7 +10,7 @@ use Socket qw(AF_UNIX SOCK_STREAM);
use Carp qw(confess croak);
use PublicInbox::Sigfd;
my ($enc, $dec);
-# ->imports at BEGIN turns serial_*_with_object into custom ops on 5.14+
+# ->imports at BEGIN turns sereal_*_with_object into custom ops on 5.14+
# and eliminate method call overhead
BEGIN {
eval {
@@ -71,9 +71,10 @@ sub ipc_worker_loop ($$) {
}
}
+# starts a worker if Sereal or Storable is installed
sub ipc_worker_spawn {
my ($self, $ident, $oldset) = @_;
- return unless $enc;
+ return unless $enc; # no Sereal or Storable
my $pid = $self->{-ipc_worker_pid};
confess "BUG: already spawned PID:$pid" if $pid;
confess "BUG: already have worker socket" if $self->{-ipc_sock};
@@ -108,15 +109,17 @@ sub ipc_worker_reap { # dwaitpid callback
warn "PID:$pid died with \$?=$?\n" if $?;
}
-# for base class, override in superclasses
+# for base class, override in sub classes
sub ipc_atfork_parent {}
sub ipc_atfork_child {}
+# should only be called inside the worker process
sub ipc_worker_exit {
my (undef, $code) = @_;
exit($code);
}
+# idempotent, can be called regardless of whether worker is active or not
sub ipc_worker_stop {
my ($self) = @_;
my $pid;
@@ -147,6 +150,7 @@ sub ipc_lock_init {
$self->{-ipc_lock} //= bless { lock_path => $f }, 'PublicInbox::Lock'
}
+# call $self->$sub(@args), on a worker if ipc_worker_spawn was used
sub ipc_do {
my ($self, $sub, @args) = @_;
if (my $s1 = $self->{-ipc_sock}) {
next prev parent reply other threads:[~2021-01-03 2:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-03 2:06 [PATCH 0/7] v2: swap in new IPC package Eric Wong
2021-01-03 2:06 ` Eric Wong [this message]
2021-01-03 2:06 ` [PATCH 2/7] searchidxshard: use PublicInbox::IPC to kill lots of code Eric Wong
2021-01-03 2:06 ` [PATCH 3/7] searchidxshard: IPC conversion, part 2 Eric Wong
2021-01-03 2:06 ` [PATCH 4/7] searchidxshard: replace index_raw with index_eml Eric Wong
2021-01-03 2:06 ` [PATCH 5/7] use Eml (or MIME) objects for all indexing paths Eric Wong
2021-01-03 2:06 ` [PATCH 6/7] ipc: switch to one-way pipes Eric Wong
2021-01-03 2:06 ` [PATCH 7/7] searchidxshard: use add_xapian directly for v2 Eric Wong
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=20210103020617.15719-2-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).