# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
+use autodie qw(seek);
use Fcntl qw(SEEK_SET);
use PublicInbox::Search;
my $addr = 'meta@public-inbox.org';
my $t = time;
utime($t, $t, $fh);
} else {
- seek($fh, 0, SEEK_SET) or die "seek: $!";
+ seek $fh, 0, SEEK_SET;
truncate($fh, 0) or die "truncate: $!";
print $fh $s or die "print: $!";
close $fh or die "close: $!";
use IO::Handle; # ->flush
use Errno qw(EEXIST);
use File::Path ();
+use autodie qw(seek sysseek);
sub new {
my ($class, $dir) = @_;
sub fh {
my ($self) = @_;
my $fh = $self->{fh} or die "BUG: {fh} not open";
- seek($fh, 0, SEEK_SET) or die "seek: $!";
- sysseek($fh, 0, SEEK_SET) or die "sysseek: $!";
+ seek $fh, 0, SEEK_SET;
+ sysseek $fh, 0, SEEK_SET;
$fh;
}
$host =~ s/:([0-9]+)\z// and $env->{SERVER_PORT} = $1 + 0;
$env->{SERVER_NAME} = $host;
}
- if (defined $input) {
- sysseek($input, 0, SEEK_SET) or
- die "BUG: psgi.input seek failed: $!";
- }
+ sysseek($input, 0, SEEK_SET) if defined $input;
# note: NOT $self->{sock}, we want our close (+ PublicInbox::DS::close),
# to do proper cleanup:
$env->{'psgix.io'} = $self; # for ->close or async_pass
use strict;
use v5.10.1;
use File::Temp 0.19 (); # 0.19 for ->newdir
-use autodie qw(mkdir);
+use autodie qw(mkdir sysseek);
use Fcntl qw(SEEK_SET);
use PublicInbox::Git qw(git_unquote git_quote git_exe);
use PublicInbox::IO qw(write_file);
my $in = tmpfile("update-index.$oid_full") or die "tmpfile: $!";
print $in "$mode_a $oid_full\t$path_a\0" or die "print: $!";
$in->flush or die "flush: $!";
- sysseek($in, 0, SEEK_SET) or die "seek: $!";
+ sysseek $in, 0, SEEK_SET;
dbg($self, 'preparing index');
my $rdr = { 0 => $in };
sub dbg_log ($) {
my ($ctx) = @_;
my $log = delete $ctx->{lh} // die 'BUG: already captured debug log';
- if (!CORE::seek($log, 0, SEEK_SET)) {
- warn "seek(log): $!";
- return '<pre>debug log seek error</pre>';
- }
- $log = eval { PublicInbox::IO::read_all $log } // do {
+ $log = eval {
+ seek $log, 0, SEEK_SET;
+ PublicInbox::IO::read_all $log;
+ } // do {
warn "read(log): $@";
return '<pre>debug log read error</pre>';
};
-# Copyright (C) 2016-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>
# This package can either be a PSGI response body for a static file
use strict;
use v5.10.1;
use parent qw(Exporter);
+use autodie qw(sysseek);
use Fcntl qw(SEEK_SET O_RDONLY O_NONBLOCK);
use HTTP::Date qw(time2str);
use HTTP::Status qw(status_message);
my $len = $self->{len} or return; # undef, tells server we're done
my $n = 8192;
$n = $len if $len < $n;
- sysseek($self->{in}, $self->{off}, SEEK_SET) or
- die "sysseek ($self->{path}): $!";
+ sysseek $self->{in}, $self->{off}, SEEK_SET;
my $r = sysread($self->{in}, my $buf, $n);
if (defined $r && $r > 0) { # success!
$self->{len} = $len - $r;
# Parallel WWW checker
my $usage = "$0 [-j JOBS] [-s SLOW_THRESHOLD] URL_OF_INBOX\n";
use strict;
-use warnings;
+use v5.10.1;
+use autodie qw(sysseek);
use File::Temp qw(tempfile);
use GDBM_File;
use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
#!perl -w
-# Copyright (C) 2020-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>
use strict;
+use v5.10.1;
+use autodie qw(seek);
use PublicInbox::TestCommon;
use Test::More;
use Fcntl qw(:seek);
$fh->autoflush(1);
ok(!$gcf2->cat_oid(fileno($fh), 'invalid'), 'invalid fails');
- seek($fh, 0, SEEK_SET) or BAIL_OUT "seek: $!";
+ seek $fh, 0, SEEK_SET;
is(do { local $/; <$fh> }, '', 'nothing written');
open $fh, '+>', undef or BAIL_OUT "open: $!";
ok(!$gcf2->cat_oid(fileno($fh), '0'x40), 'z40 fails');
- seek($fh, 0, SEEK_SET) or BAIL_OUT "seek: $!";
+ seek $fh, 0, SEEK_SET;
is(do { local $/; <$fh> }, '', 'nothing written for z40');
open $fh, '+>', undef or BAIL_OUT "open: $!";
my $ck_copying = sub {
my ($desc) = @_;
- seek($fh, 0, SEEK_SET) or BAIL_OUT "seek: $!";
+ seek $fh, 0, SEEK_SET;
is(<$fh>, "$COPYING blob 34520\n", "got expected header $desc");
my $buf = do { local $/; <$fh> };
is(chop($buf), "\n", 'got trailing \\n');
fcntl($w, $F_SETPIPE_SZ, 4096) or
skip('Linux too old for F_SETPIPE_SZ', 14);
$w->blocking($blk);
- seek($fh, 0, SEEK_SET) or BAIL_OUT "seek: $!";
+ seek $fh, 0, SEEK_SET;
truncate($fh, 0) or BAIL_OUT "truncate: $!";
my $pid = fork // BAIL_OUT "fork: $!";
if ($pid == 0) {
ok($filter->write("hello"), 'wrote something');
ok($filter->write("world"), 'wrote more');
$filter->close;
- seek($fh, 0, SEEK_SET) or die;
+ seek $fh, 0, SEEK_SET;
IO::Uncompress::Gunzip::gunzip($fh => \(my $buf));
is($buf, 'helloworld', 'buffer matches');
}
# generic PSGI/Plack apps.
use v5.12; use PublicInbox::TestCommon;
use Time::HiRes qw(gettimeofday tv_interval);
-use autodie qw(getsockopt setsockopt);
+use autodie qw(getsockopt seek setsockopt);
use PublicInbox::Spawn qw(spawn popen_rd);
require_mods '-httpd';
use PublicInbox::SHA qw(sha1_hex);
$req = GET('http://example.com/psgi-yield-enoent');
$res = $cb->($req);
is($res->code, 500, 'got error on ENOENT');
- seek($tmperr, 0, SEEK_SET) or die;
+ seek $tmperr, 0, SEEK_SET;
my $errbuf = do { local $/; <$tmperr> };
like($errbuf, qr/this-better-not-exist/,
'error logged about missing command');
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use v5.10.1;
use strict;
+use autodie qw(seek);
use PublicInbox::Eml;
use PublicInbox::Smsg;
use PublicInbox::Git;
open my $in, '+<', undef or BAIL_OUT "open(+<): $!";
print $in $mime->as_string or die "write failed: $!";
$in->flush or die "flush failed: $!";
- seek($in, 0, SEEK_SET) or die "seek: $!";
+ seek $in, 0, SEEK_SET;
chomp(my $hashed_obj = xqx(\@cmd, undef, { 0 => $in }));
is($?, 0, 'hash-object');
is($hashed_obj, $smsg->{blob}, "blob object_id matches exp");
# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use v5.12;
+use autodie qw(seek);
use PublicInbox::TestCommon;
use Fcntl qw(SEEK_SET);
use PublicInbox::SHA qw(sha1_hex);
$ipc->wq_close;
SKIP: {
skip 'Socket::MsgHdr or Inline::C missing', 11 if !$ppids[0];
- seek($warn, 0, SEEK_SET) or BAIL_OUT;
+ seek $warn, 0, SEEK_SET;
my @warn = <$warn>;
is(scalar(@warn), 2, 'warned 3 times');
like($warn[0], qr/ wq_worker: /, '2nd warned from wq_worker');
#!perl -w
-# Copyright (C) 2020-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>
use strict; use v5.10.1; use PublicInbox::TestCommon;
use Fcntl qw(SEEK_SET);
+use autodie qw(seek);
require_git 2.6;
require_mods(qw(json DBD::SQLite Xapian));
use POSIX qw(WTERMSIG WIFSIGNALED SIGPIPE);
open my $fh, '+>', undef or BAIL_OUT $!;
$fh->autoflush(1);
print $fh 's:use d:..5.days.from.now' or BAIL_OUT $!;
- seek($fh, 0, SEEK_SET) or BAIL_OUT $!;
+ seek $fh, 0, SEEK_SET;
lei_ok([qw(q -q --stdin)], undef, { %$lei_opt, 0 => $fh },
\'--stdin on regular file works');
like($lei_out, qr/use boolean/, '--stdin on regular file');
#!perl -w
-# 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>
use strict; use v5.10.1; use PublicInbox::TestCommon;
+use autodie qw(sysseek);
require_git 2.6;
require_mods(qw(json DBD::SQLite Xapian));
lei_ok([qw(p2q -w dfpost -)], undef, { %$lei_opt, 0 => $fh });
is($lei_out, "dfpost:6e006fd73b1d\n", '--stdin') or diag $lei_err;
- sysseek($fh, 0, 0) or xbail "lseek: $!";
+ sysseek $fh, 0, 0;
lei_ok([qw(p2q -w dfpost)], undef, { %$lei_opt, 0 => $fh });
is($lei_out, "dfpost:6e006fd73b1d\n", 'implicit --stdin');
close $w;
vec(my $rvec = '', fileno($r), 1) = 1;
if (!select($rvec, undef, undef, 30)) {
- seek($errfh, 0, 0);
+ seek $errfh, 0, 0;
my $s = do { local $/; <$errfh> };
xbail "lei q had no output after 30s, stderr=$s";
}
$tp->join;
ok(WIFSIGNALED($?), "signaled @$out");
is(WTERMSIG($?), SIGPIPE, "got SIGPIPE @$out");
- seek($errfh, 0, 0);
+ seek $errfh, 0, 0;
my $s = do { local $/; <$errfh> };
is($s, '', "quiet after sigpipe @$out");
}
#!perl -w
-# Copyright (C) 2020-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>
use strict;
use v5.10.1;
-use Test::More;
+use autodie qw(seek);
use PublicInbox::TestCommon;
use List::Util qw(shuffle);
use PublicInbox::Eml;
my $buf = $eml2mbox->($eml);
print $fh $$buf or BAIL_OUT "print $!";
}
- seek($fh, 0, SEEK_SET) or BAIL_OUT "seek: $!";
+ seek $fh, 0, SEEK_SET;
$reader->$fmt($fh, sub {
my ($eml) = @_;
$eml->header_set('Status');