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 16/21] spawn: use autodie and PublicInbox::Lock
  2023-10-04  3:49  6% [PATCH 00/21] lei + IPC related stuff Eric Wong
@ 2023-10-04  3:49  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-10-04  3:49 UTC (permalink / raw)
  To: meta

It keeps Spawn.pm less noisy and ensures retries on EINTR.
---
 lib/PublicInbox/Spawn.pm | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm
index 75ef0137..0dffe064 100644
--- a/lib/PublicInbox/Spawn.pm
+++ b/lib/PublicInbox/Spawn.pm
@@ -17,7 +17,8 @@
 package PublicInbox::Spawn;
 use v5.12;
 use parent qw(Exporter);
-use Fcntl qw(LOCK_EX SEEK_SET);
+use PublicInbox::Lock;
+use Fcntl qw(SEEK_SET);
 use IO::Handle ();
 use Carp qw(croak);
 use PublicInbox::ProcessPipe;
@@ -285,26 +286,25 @@ ALL_LIBC
 	$all_libc = undef unless -d _ && -w _;
 	if (defined $all_libc) {
 		local $ENV{PERL_INLINE_DIRECTORY} = $inline_dir;
-		my $f = "$inline_dir/.public-inbox.lock";
-		open my $oldout, '>&', \*STDOUT or die "dup(1): $!";
-		open my $olderr, '>&', \*STDERR or die "dup(2): $!";
-		open my $fh, '+>', $f or die "open($f): $!";
-		open STDOUT, '>&', $fh or die "1>$f: $!";
-		open STDERR, '>&', $fh or die "2>$f: $!";
+		use autodie;
+		# CentOS 7.x ships Inline 0.53, 0.64+ has built-in locking
+		my $lk = PublicInbox::Lock->new($inline_dir.
+						'/.public-inbox.lock');
+		my $fh = $lk->lock_acquire;
+		open my $oldout, '>&', \*STDOUT;
+		open my $olderr, '>&', \*STDERR;
+		open STDOUT, '>&', $fh;
+		open STDERR, '>&', $fh;
 		STDERR->autoflush(1);
 		STDOUT->autoflush(1);
-
-		# CentOS 7.x ships Inline 0.53, 0.64+ has built-in locking
-		flock($fh, LOCK_EX) or die "LOCK_EX($f): $!";
-		eval <<'EOM';
-use Inline C => $all_libc, BUILD_NOISY => 1;
-EOM
+		CORE::eval 'use Inline C => $all_libc, BUILD_NOISY => 1';
 		my $err = $@;
-		open(STDERR, '>&', $olderr) or warn "restore stderr: $!";
-		open(STDOUT, '>&', $oldout) or warn "restore stdout: $!";
+		open(STDERR, '>&', $olderr);
+		open(STDOUT, '>&', $oldout);
 		if ($err) {
 			seek($fh, 0, SEEK_SET);
 			my @msg = <$fh>;
+			truncate($fh, 0);
 			warn "Inline::C build failed:\n", $err, "\n", @msg;
 			$all_libc = undef;
 		}

^ permalink raw reply related	[relevance 7%]

* [PATCH 00/21] lei + IPC related stuff
@ 2023-10-04  3:49  6% Eric Wong
  2023-10-04  3:49  7% ` [PATCH 16/21] spawn: use autodie and PublicInbox::Lock Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-10-04  3:49 UTC (permalink / raw)
  To: meta

More work coming to make internal IPC stuff simpler
and better layered for future enhancements
(FUSE, increase xap_helper usage internally, etc).

Eric Wong (21):
  lei: drop stores explicitly at daemon shutdown
  ds: hoist out close_non_busy
  ds: don't pass FD map to post_loop_do callback
  move all non-test @post_loop_do into named subs
  lei: close DirIdle (inotify) early at daemon shutdown
  input_pipe: {args} is never undefined
  lei: do_env combines fchdir and local
  lei: get rid of l2m_progress PktOp callback
  t/lei_to_mail: modernize and document test
  lei: reuse PublicInbox::Config::noop
  lei: keep signals blocked on daemon shutdown
  mbox_lock: retry on EINTR and use autodie
  lock: retry on EINTR, improve error reporting
  treewide: use PublicInbox::Lock->new
  gcf2: use PublicInbox::Lock
  spawn: use autodie and PublicInbox::Lock
  xap_helper: retry flock on EINTR
  XapHelper.pm: use EINTR-aware recv_cmd wrapper
  spawn: drop checks for directory writability
  lei: document and local-ize $OPT hashref
  searchidx: fix redundant `in' in warning message

 lib/PublicInbox/DS.pm         |  17 +++--
 lib/PublicInbox/Daemon.pm     |  47 ++++++-------
 lib/PublicInbox/DirIdle.pm    |  12 +++-
 lib/PublicInbox/Gcf2.pm       |   8 ++-
 lib/PublicInbox/IPC.pm        |   4 +-
 lib/PublicInbox/InputPipe.pm  |  11 ++-
 lib/PublicInbox/LEI.pm        | 127 ++++++++++++++++------------------
 lib/PublicInbox/LeiAuth.pm    |   4 +-
 lib/PublicInbox/LeiConfig.pm  |  25 +++----
 lib/PublicInbox/LeiConvert.pm |   7 +-
 lib/PublicInbox/LeiInspect.pm |  28 ++++----
 lib/PublicInbox/LeiLcat.pm    |  17 +++--
 lib/PublicInbox/LeiMirror.pm  |   2 +-
 lib/PublicInbox/LeiQuery.pm   |  19 +++--
 lib/PublicInbox/LeiTag.pm     |   6 +-
 lib/PublicInbox/LeiToMail.pm  |  20 +++---
 lib/PublicInbox/LeiXSearch.pm | 113 +++++++++++++-----------------
 lib/PublicInbox/Lock.pm       |  52 ++++++++------
 lib/PublicInbox/MboxLock.pm   |  49 ++++++-------
 lib/PublicInbox/PktOp.pm      |  15 ++--
 lib/PublicInbox/SearchIdx.pm  |   2 +-
 lib/PublicInbox/Spawn.pm      |  32 ++++-----
 lib/PublicInbox/TestCommon.pm |   7 +-
 lib/PublicInbox/Watch.pm      |   4 +-
 lib/PublicInbox/XapHelper.pm  |  11 ++-
 lib/PublicInbox/xap_helper.h  |   6 +-
 t/lei-tag.t                   |   3 +
 t/lei_to_mail.t               |  37 +++++-----
 t/solver_git.t                |   3 +-
 t/v2mirror.t                  |   2 +-
 30 files changed, 339 insertions(+), 351 deletions(-)

^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-10-04  3:49  6% [PATCH 00/21] lei + IPC related stuff Eric Wong
2023-10-04  3:49  7% ` [PATCH 16/21] spawn: use autodie and PublicInbox::Lock 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).