From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/3] lei note-event: fix explicit flush reliability
Date: Fri, 15 Oct 2021 13:30:56 +0000 [thread overview]
Message-ID: <20211015133056.6845-4-e@80x24.org> (raw)
In-Reply-To: <20211015133056.6845-1-e@80x24.org>
We need to send the socket over to lei/store and wait for the
kernel to drop the socket refcount down to zero before
script/lei can exit.
This is not a new bug and only caused very sporadic test
failures. I only noticed it while simplifying IPC stuff.
---
lib/PublicInbox/LeiNoteEvent.pm | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/lib/PublicInbox/LeiNoteEvent.pm b/lib/PublicInbox/LeiNoteEvent.pm
index ba4dfd49..1749c98f 100644
--- a/lib/PublicInbox/LeiNoteEvent.pm
+++ b/lib/PublicInbox/LeiNoteEvent.pm
@@ -11,10 +11,11 @@ use PublicInbox::DS;
our $to_flush; # { cfgpath => $lei }
-sub flush_lei ($) {
- my ($lei) = @_;
- my $lne = delete $lei->{cfg}->{-lei_note_event};
- $lne->wq_close if $lne; # runs _lei_wq_eof;
+sub flush_lei ($;$) {
+ my ($lei, $manual) = @_;
+ my $lne = delete $lei->{cfg}->{-lei_note_event} // return;
+ $lne->{lei_sock} = $lei->{sock} if $manual;
+ $lne->wq_close; # runs _lei_wq_eof;
}
# we batch up writes and flush every 5s (matching Linux default
@@ -67,7 +68,7 @@ sub lei_note_event {
die "BUG: unexpected: @rest" if @rest;
my $cfg = $lei->_lei_cfg or return; # gone (race)
my $sto = $lei->_lei_store or return; # gone
- return flush_lei($lei) if $folder eq 'done'; # special case
+ return flush_lei($lei, 1) if $folder eq 'done'; # special case
my $lms = $lei->lms or return;
$lms->lms_write_prepare if $new_cur eq ''; # for ->clear_src below
$lei->{opt}->{quiet} = 1;
@@ -111,8 +112,8 @@ sub ipc_atfork_child {
sub _lei_wq_eof { # EOF callback for main lei daemon
my ($lei) = @_;
- delete $lei->{lne} or return $lei->fail;
- $lei->sto_done_request;
+ my $lne = delete $lei->{lne} or return $lei->fail;
+ $lei->sto_done_request($lne->{lei_sock});
}
1;
prev parent reply other threads:[~2021-10-15 13:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 13:30 [PATCH 0/3] lei bugfixes and simplifications Eric Wong
2021-10-15 13:30 ` [PATCH 1/3] lei forget-search: fix for symlink-ed paths Eric Wong
2021-10-15 13:30 ` [PATCH 2/3] lei + ipc: simplify process reaping Eric Wong
2021-10-15 13:45 ` [SQUASH PATCH 4/3] lei q: ensure all workers die on Ctrl-C Eric Wong
2021-10-15 13:30 ` 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=20211015133056.6845-4-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).