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,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF 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 E7AAD1F454 for ; Thu, 5 Oct 2023 00:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1696467591; bh=H6aUX36U1SZ/+OWwHUwfxlnyFwN9h6peefdRDymgjIk=; h=Date:From:To:Subject:From; b=3MSgxdoiyRCZJqix3URueEeX5f06NbsnbqWY6LBEF7qfjgpgQnHNrwFfspPLpv4aA uj6KuaGLSCGBoalfdjvgBUwb2sZ3sK2vnuXy5Rg94sc3OWSY4kReO4+/wKifuPurgj fEQ5LHJPHmhINiZAuIsmA8dD+qleucIWbsQKfniM= Date: Thu, 5 Oct 2023 00:59:50 +0000 From: Eric Wong To: spew@80x24.org Subject: dfly wip Message-ID: <20231005005950.M790022@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline List-Id: diff --git a/ci/profiles.perl b/ci/profiles.perl index 6f90a0e4..c815427d 100755 --- a/ci/profiles.perl +++ b/ci/profiles.perl @@ -7,7 +7,7 @@ if 0; # running under some shell use v5.12; BEGIN { require './install/os.perl' } my $TASKS = do { - if ($ID =~ /\A(?:free|net|open)bsd\z/) { <[2]) // die "BUG: bad fileno $w->[2]: $!"; $self->{dskq}->{kq}->EV_SET($ident, # ident (fd) EVFILT_VNODE, # filter - EV_ADD | EV_CLEAR, # flags + EV_ADD, # flags $mask, # fflags 0, $dir_delete); # data, udata $self->{watch}->{$ident} = $w; diff --git a/lib/PublicInbox/POP3D.pm b/lib/PublicInbox/POP3D.pm index 2a9ccfdd..38e982ee 100644 --- a/lib/PublicInbox/POP3D.pm +++ b/lib/PublicInbox/POP3D.pm @@ -15,7 +15,7 @@ use File::Temp 0.19 (); # 0.19 for ->newdir use Fcntl qw(F_SETLK F_UNLCK F_WRLCK SEEK_SET); my ($FLOCK_TMPL, @FLOCK_ORDER); # are all BSDs the same "struct flock"? tested Free+Net+Open... -if ($^O eq 'linux' || $^O =~ /bsd/) { +if ($^O =~ /\A(?:linux|dragonfly)\z/ || $^O =~ /bsd/) { require Config; my $off_t; my $sz = $Config::Config{lseeksize}; @@ -28,7 +28,7 @@ if ($^O eq 'linux' || $^O =~ /bsd/) { if ($^O eq 'linux') { $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 + } else { # *bsd including dragonfly $FLOCK_TMPL = "${off_t}${off_t}lss\@256"; @FLOCK_ORDER = qw(l_start l_len l_pid l_type l_whence); } diff --git a/t/dir_idle.t b/t/dir_idle.t index bb6f47eb..02759b54 100644 --- a/t/dir_idle.t +++ b/t/dir_idle.t @@ -1,7 +1,7 @@ #!perl -w # Copyright (C) all contributors # License: AGPL-3.0+ -use v5.12; use strict; use PublicInbox::TestCommon; +use v5.12; use PublicInbox::TestCommon; use PublicInbox::DS qw(now); use File::Path qw(make_path); use_ok 'PublicInbox::DirIdle'; @@ -26,10 +26,12 @@ rmdir("$tmpdir/a") or xbail "rmdir $!"; @x = (); $end = 3 + now; PublicInbox::DS::event_loop(); -is(scalar(@x), 1, 'got an event') and +if (is(scalar(@x), 1, 'got an event after rmdir')) { is($x[0]->[0]->fullname, "$tmpdir/a", 'got expected fullname') and ok($x[0]->[0]->IN_DELETE_SELF, 'IN_DELETE_SELF set'); - +} else { + diag explain(\@x); +} rename("$tmpdir/c", "$tmpdir/j") or xbail "rmdir $!"; @x = (); $end = 3 + now; diff --git a/t/ds-kqxs.t b/t/ds-kqxs.t index 57acb53f..87f7199d 100644 --- a/t/ds-kqxs.t +++ b/t/ds-kqxs.t @@ -6,8 +6,9 @@ use v5.12; use Test::More; unless (eval { require IO::KQueue }) { - my $m = $^O !~ /bsd/ ? 'DSKQXS is only for *BSD systems' - : "no IO::KQueue, skipping $0: $@"; + my $m = ($^O =~ /bsd/ || $^O eq 'dragonfly') ? + "no IO::KQueue, skipping $0: $@" : + 'DSKQXS is only for *BSD systems'; plan skip_all => $m; } diff --git a/t/kqnotify.t b/t/kqnotify.t index edecf2e1..94f76c84 100644 --- a/t/kqnotify.t +++ b/t/kqnotify.t @@ -7,7 +7,8 @@ use v5.12; use PublicInbox::TestCommon; use autodie; -plan skip_all => 'KQNotify is only for *BSD systems' if $^O !~ /bsd/; +($^O =~ /bsd/ || $^O eq 'dragonfly') or + plan skip_all => 'KQNotify is only for *BSD systems'; require_mods('IO::KQueue'); use_ok 'PublicInbox::KQNotify'; my ($tmpdir, $for_destroy) = tmpdir(); @@ -33,9 +34,35 @@ $hit = [ grep(m!/link$!, @read) ]; is_deeply($hit, ["$tmpdir/new/link"], 'link(2) detected (via NOTE_WRITE)') or diag explain(\@read); +{ + my $d = "$tmpdir/new/ANOTHER"; + mkdir $d; + $hit = [ map { $_->fullname } $kqn->read ]; + is_xdeeply($hit, [ $d ], 'mkdir detected'); + # no way to avoid detecting deletes if we're watching for dir ops + rmdir $d; + is_xdeeply($hit, [ $d ], 'rmdir detected'); +} + $w->cancel; link("$tmpdir/new/tst", "$tmpdir/new/link2"); $hit = [ map { $_->fullname } $kqn->read ]; is_deeply($hit, [], 'link(2) not detected after cancel'); +# rearm: +my $GONE = PublicInbox::KQNotify::NOTE_DELETE() | + PublicInbox::KQNotify::NOTE_REVOKE() | + PublicInbox::KQNotify::NOTE_ATTRIB() | + PublicInbox::KQNotify::NOTE_WRITE() | + PublicInbox::KQNotify::NOTE_RENAME(); +$w = $kqn->watch("$tmpdir/new", $mask|$GONE); +my @unlink = sort glob("$tmpdir/new/*"); +unlink(@unlink); +$hit = [ sort(map { $_->fullname } $kqn->read) ]; +is_xdeeply($hit, \@unlink, 'unlinked files match'); + +rmdir "$tmpdir/new"; +$hit = [ sort(map { $_->fullname } $kqn->read) ]; +is(scalar(@$hit), 1, 'detected self removal'); + done_testing; diff --git a/t/pop3d-limit.t b/t/pop3d-limit.t index 00da477d..1aa83119 100644 --- a/t/pop3d-limit.t +++ b/t/pop3d-limit.t @@ -4,7 +4,7 @@ use v5.12; use PublicInbox::TestCommon; require_mods(qw(DBD::SQLite Net::POP3)); -$^O =~ /\A(?:linux|(?:free|net|open)bsd)\z/ or +($^O =~ /\A(?:linux|dragonfly)\z/ || $^O =~ /bsd/) or require_mods(qw(File::FcntlLock)); use autodie; my ($tmpdir, $for_destroy) = tmpdir(); diff --git a/t/pop3d.t b/t/pop3d.t index fce4a788..e698b905 100644 --- a/t/pop3d.t +++ b/t/pop3d.t @@ -14,7 +14,7 @@ unless (-r $key && -r $cert) { # Net::POP3 is part of the standard library, but distros may split it off... require_mods(qw(DBD::SQLite Net::POP3 IO::Socket::SSL)); require_git('2.6'); # for v2 -$^O =~ /\A(?:linux|(?:free|net|open)bsd)\z/ or +($^O =~ /\A(?:linux|dragonfly)\z/ || $^O =~ /bsd/) or require_mods(qw(File::FcntlLock)); use_ok 'IO::Socket::SSL'; use_ok 'PublicInbox::TLS'; diff --git a/t/search.t b/t/search.t index 636dc5cf..9ed3cd25 100644 --- a/t/search.t +++ b/t/search.t @@ -440,7 +440,7 @@ my $dir_mask = 02770; # FreeBSD, OpenBSD and NetBSD do not allow non-root users to set S_ISGID, # so git doesn't set it, either (see DIR_HAS_BSD_GROUP_SEMANTICS in git.git) # Presumably all *BSDs behave the same way. -if ($^O =~ /\A.+bsd\z/i) { +if ($^O =~ /bsd/ || $^O eq 'dragonfly') { $all_mask = 0777; $dir_mask = 0770; }