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 6/8] pop3d: split @FLOCK into $FLOCK_TMPL and @FLOCK_ORDER
Date: Mon, 18 Sep 2023 10:15:14 +0000	[thread overview]
Message-ID: <20230918101516.2477899-7-e@80x24.org> (raw)
In-Reply-To: <20230918101516.2477899-1-e@80x24.org>

This improves readability since we don't have to subscript
the array for use with the `pack' perlop.
---
 lib/PublicInbox/POP3D.pm | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/PublicInbox/POP3D.pm b/lib/PublicInbox/POP3D.pm
index 580a26d3..bee668fc 100644
--- a/lib/PublicInbox/POP3D.pm
+++ b/lib/PublicInbox/POP3D.pm
@@ -13,7 +13,7 @@ use PublicInbox::POP3;
 use PublicInbox::Syscall;
 use File::Temp 0.19 (); # 0.19 for ->newdir
 use Fcntl qw(F_SETLK F_UNLCK F_WRLCK SEEK_SET);
-my @FLOCK;
+my ($FLOCK_TMPL, @FLOCK_ORDER);
 # are all BSDs the same "struct flock"? tested Free+Net+Open...
 if ($^O eq 'linux' || $^O =~ /bsd/) {
 	require Config;
@@ -26,15 +26,15 @@ if ($^O eq 'linux' || $^O =~ /bsd/) {
 
 	if (defined($off_t)) {
 		if ($^O eq 'linux') {
-			@FLOCK = ("ss\@8$off_t$off_t\@32",
-				qw(l_type l_whence l_start l_len));
+			$FLOCK_TMPL = "ss\@8$off_t$off_t\@32";
+			@FLOCK_ORDER = qw(l_type l_whence l_start l_len);
 		} elsif ($^O =~ /bsd/) { # @32 may be enough
-			@FLOCK = ("${off_t}${off_t}lss\@256",
-				qw(l_start l_len l_pid l_type l_whence));
+			$FLOCK_TMPL = "${off_t}${off_t}lss\@256";
+			@FLOCK_ORDER = qw(l_start l_len l_pid l_type l_whence);
 		}
 	}
 }
-@FLOCK or eval { require File::FcntlLock } or
+@FLOCK_ORDER or eval { require File::FcntlLock } or
 	die "File::FcntlLock required for POP3 on $^O: $@\n";
 
 sub new {
@@ -141,9 +141,9 @@ sub _setlk ($%) {
 	my ($self, %lk) = @_;
 	$lk{l_pid} = 0; # needed for *BSD
 	$lk{l_whence} = SEEK_SET;
-	if (@FLOCK) {
+	if (@FLOCK_ORDER) {
 		fcntl($self->{txn_fh}, F_SETLK,
-			pack($FLOCK[0], @lk{@FLOCK[1..$#FLOCK]}));
+			pack($FLOCK_TMPL, @lk{@FLOCK_ORDER}));
 	} else {
 		my $fs = File::FcntlLock->new(%lk);
 		$fs->lock($self->{txn_fh}, F_SETLK);

  parent reply	other threads:[~2023-09-18 10:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18 10:15 [PATCH 0/8] portability odds and ends Eric Wong
2023-09-18 10:15 ` [PATCH 1/8] ci/run: favor `make check' as the default target Eric Wong
2023-09-18 10:15 ` [PATCH 2/8] drop GNU nproc(1) support in favor of getconf(1) Eric Wong
2023-09-18 10:15 ` [PATCH 3/8] ipc: assume SOCK_SEQPACKET exists Eric Wong
2023-09-18 10:15 ` [PATCH 4/8] rename t/run.perl to xt/check-run Eric Wong
2023-09-18 10:15 ` [PATCH 5/8] makefile: avoid needless use of double-colon rules Eric Wong
2023-09-18 10:15 ` Eric Wong [this message]
2023-09-18 10:15 ` [PATCH 7/8] install/deps: more fixes Eric Wong
2023-09-18 10:15 ` [PATCH 8/8] makefile: avoid non-POSIX which(1) 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=20230918101516.2477899-7-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).