From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 10B211F405; Thu, 1 Feb 2024 21:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1706821471; bh=dx3nGtfUIm3Hhd2u9Ru9K1WcGG+LgoSp3V30i08b6RI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LjGh1cif6WpV1HmHhGz1pjOs5KrbFERdD0z0PurM5+nV1OGBmFLj/Xep6B+JuFlN/ OuEL3lzWLOc42Df1THKduWzYzyP838iqcTXZumZNDfd62Wl0lEI2+RUeUYJIFaR3KM pskYpVUHVRqrJnRjEniEltF2/h3W/axjBte2cIio= Date: Thu, 1 Feb 2024 20:59:48 +0000 From: Eric Wong To: meta@public-inbox.org Cc: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= Subject: [PATCH v2] pop3d: support fcntl locks on OpenBSD i386 Message-ID: <20240201205948.M815900@dcvr> References: <20240201001219.1314010-1-e@80x24.org> <20240201111512+0100.214403-stepnem@smrk.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240201111512+0100.214403-stepnem@smrk.net> List-Id: Štěpán Němec wrote: > Eric Wong wrote: > > > AFAIK File::FcntlLock isn't packaged for OpenBSD, > > https://openports.pl/path/devel/p5-File-FcntlLock > https://ftp.openbsd.org/pub/OpenBSD/snapshots/packages/amd64/p5-File-FcntlLock-0.22.tgz > > (apparently only added a few months ago, so it's not in any > release yet; should be available starting with 7.5 (due in > May or thereabouts)) Thanks for the info. Updated commit message and fixed parentheses in warning message below. Sidenote: 64-bit file offsets in an interpreter without 64-bit integer support is a strange combination. I don't understand why it was chosen by the OpenBSD folks nor why Perl allows it... Can anybody enlighten me? -------8<------ Subject: [PATCH v2] pop3d: support fcntl locks on OpenBSD i386 The packaged Perl on OpenBSD i386 supports 64-bit file offsets but not 64-bit integer support for 'q' and 'Q' with `pack'. Since servers aren't likely to require lock files larger than 2 GB (we'd need an inbox with >2 billion messages), we can workaround the Perl build limitation with explicit padding. File::FcntlLock isn't packaged for OpenBSD <= 7.4 (but should be in future releases), but I can test i386 OpenBSD on an extremely slow VM. Big endian support can be done, too, but I have no idea if there's 32-bit BE users around nowadays... --- Range-diff against v1: 1: 0dce97c6 ! 1: 75dab25f pop3d: support fcntl locks on OpenBSD i386 @@ Commit message 2 GB (we'd need an inbox with >2 billion messages), we can workaround the Perl build limitation with explicit padding. - AFAIK File::FcntlLock isn't packaged for OpenBSD, but I can - test i386 OpenBSD on an extremely slow VM. + File::FcntlLock isn't packaged for OpenBSD <= 7.4 (but should be + in future releases), but I can test i386 OpenBSD on an extremely + slow VM. Big endian support can be done, too, but I have no idea if there's 32-bit BE users around nowadays... @@ lib/PublicInbox/POP3D.pm: my ($FLOCK_TMPL, @FLOCK_ORDER); + @LE_pad = ('@8', '@16'); + } else { # I have no 32-bit BE machine to test on... + warn < +# License: AGPL-3.0+ +use v5.12; +use PublicInbox::TestCommon; +require_mods(qw(DBD::SQLite Net::POP3 :fcntl_lock)); +use autodie; +my $tmpdir = tmpdir; +require_ok 'PublicInbox::POP3D'; +my $pop3d = bless {}, 'PublicInbox::POP3D'; +open $pop3d->{txn_fh}, '+>>', "$tmpdir/txn.lock"; +use Fcntl qw(F_SETLK F_UNLCK F_WRLCK); + +ok $pop3d->_setlk(l_type => F_WRLCK, l_start => 9, l_len => 1), + 'locked file (check with ktrace/strace)'; + +done_testing;