user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH] lei: do not wait for sto->done on disconnected EOF
@ 2022-08-16  3:44  5% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2022-08-16  3:44 UTC (permalink / raw)
  To: meta

lei-daemon (the top-level daemon process) should not have
synchronous waits, and this was causing a deadlock with
interrupted commands.  There may still be a bug lurking in
lei/store despite this fix, though.  I originally thought commit
fd261b9e65674505 (lei_store_err: use level-trigger for error pipe, 2022-08-15)
was sufficient, but at least this change is needed, as well.
---
 lib/PublicInbox/LEI.pm | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index d81ca296..595b3fa9 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -1520,13 +1520,10 @@ sub sto_done_request {
 	return unless $lei->{sto};
 	local $current_lei = $lei;
 	my $sock = $wq ? $wq->{lei_sock} : undef;
-	eval {
-		if ($sock //= $lei->{sock}) { # issue, async wait
-			$lei->{sto}->wq_io_do('done', [ $sock ]);
-		} else { # forcibly wait
-			my $wait = $lei->{sto}->wq_do('done');
-		}
-	};
+	$sock //= $lei->{sock};
+	my @io;
+	push(@io, $sock) if $sock; # async wait iff possible
+	eval { $lei->{sto}->wq_io_do('done', \@io) };
 	warn($@) if $@;
 }
 

^ permalink raw reply related	[relevance 5%]

* [PATCH] lei_store_err: use level-trigger for error pipe
@ 2022-08-15 19:28  7% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2022-08-15 19:28 UTC (permalink / raw)
  To: meta

This fixes deadlocks from errors inside lei/store when multiple
errors are spewed.
---
 lib/PublicInbox/LeiStoreErr.pm | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/lib/PublicInbox/LeiStoreErr.pm b/lib/PublicInbox/LeiStoreErr.pm
index cc085fdc..47fa2277 100644
--- a/lib/PublicInbox/LeiStoreErr.pm
+++ b/lib/PublicInbox/LeiStoreErr.pm
@@ -1,13 +1,12 @@
-# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # forwards stderr from lei/store process to any lei clients using
 # the same store, falls back to syslog if no matching clients exist.
 package PublicInbox::LeiStoreErr;
-use strict;
-use v5.10.1;
+use v5.12;
 use parent qw(PublicInbox::DS);
-use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT);
+use PublicInbox::Syscall qw(EPOLLIN);
 use Sys::Syslog qw(openlog syslog closelog);
 use IO::Handle (); # ->blocking
 
@@ -15,24 +14,24 @@ sub new {
 	my ($cls, $rd, $lei) = @_;
 	my $self = bless { sock => $rd, store_path => $lei->store_path }, $cls;
 	$rd->blocking(0);
-	$self->SUPER::new($rd, EPOLLIN | EPOLLONESHOT);
+	$self->SUPER::new($rd, EPOLLIN); # level-trigger
 }
 
 sub event_step {
 	my ($self) = @_;
-	my $rbuf = $self->{rbuf} // \(my $x = '');
-	$self->do_read($rbuf, 8192, length($$rbuf)) or return;
-	my $cb;
+	my $n = sysread($self->{sock}, my $buf, 8192);
+	return ($!{EAGAIN} ? 0 : $self->close) if !defined($n);
+	return $self->close if !$n;
 	my $printed;
 	for my $lei (values %PublicInbox::DS::DescriptorMap) {
-		$cb = $lei->can('store_path') // next;
+		my $cb = $lei->can('store_path') // next;
 		next if $cb->($lei) ne $self->{store_path};
 		my $err = $lei->{2} // next;
-		print $err $$rbuf and $printed = 1;
+		print $err $buf and $printed = 1;
 	}
 	if (!$printed) {
 		openlog('lei/store', 'pid,nowait,nofatal,ndelay', 'user');
-		for my $l (split(/\n/, $$rbuf)) { syslog('warning', '%s', $l) }
+		for my $l (split(/\n/, $buf)) { syslog('warning', '%s', $l) }
 		closelog(); # don't share across fork
 	}
 }

^ permalink raw reply related	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2022-08-15 19:28  7% [PATCH] lei_store_err: use level-trigger for error pipe Eric Wong
2022-08-16  3:44  5% [PATCH] lei: do not wait for sto->done on disconnected EOF 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).