about summary refs log tree commit homepage
path: root/lib/PublicInbox/Git.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-11-02 09:35:38 +0000
committerEric Wong <e@80x24.org>2023-11-03 06:39:44 +0000
commit8d86e5b49d7f5d6e0b1768d0bd55fd21df36f86e (patch)
tree74c292ea35d4963525327cc5f7e64dc975156fee /lib/PublicInbox/Git.pm
parent3aa444b4c4eef1c40a49e5db191eb844c6624b58 (diff)
downloadpublic-inbox-8d86e5b49d7f5d6e0b1768d0bd55fd21df36f86e.tar.gz
The IO package seems like a better home for I/O subs than the
Git package.  We lose the 60 second read timeout for `git
cat-file --batch-*' processes since it's probably not necessary
given how reliable the code has proven and things would fall
over hard in other ways if the storage device were completely
hosed.
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r--lib/PublicInbox/Git.pm24
1 files changed, 2 insertions, 22 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index d00f576e..11712db2 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -18,16 +18,14 @@ use Errno qw(EINTR EAGAIN);
 use File::Glob qw(bsd_glob GLOB_NOSORT);
 use File::Spec ();
 use PublicInbox::Spawn qw(spawn popen_rd run_qx which);
-use PublicInbox::IO;
+use PublicInbox::IO qw(poll_in read_all try_cat);
 use PublicInbox::Tmpfile;
-use IO::Poll qw(POLLIN);
 use Carp qw(croak carp);
 use PublicInbox::SHA qw(sha_all);
 our %HEXLEN2SHA = (40 => 1, 64 => 256);
 our %OFMT2HEXLEN = (sha1 => 40, sha256 => 64);
-our @EXPORT_OK = qw(git_unquote git_quote %HEXLEN2SHA %OFMT2HEXLEN read_all);
+our @EXPORT_OK = qw(git_unquote git_quote %HEXLEN2SHA %OFMT2HEXLEN);
 our $in_cleanup;
-our $RDTIMEO = 60_000; # milliseconds
 our $async_warn; # true in read-only daemons
 
 # committerdate:unix is git 2.9.4+ (2017-05-05), so using raw instead
@@ -168,8 +166,6 @@ sub _sock_cmd {
         $self->{sock} = PublicInbox::IO::attach_pid($s1, $pid);
 }
 
-sub poll_in ($) { IO::Poll::_poll($RDTIMEO, fileno($_[0]), my $ev = POLLIN) }
-
 sub my_read ($$$) {
         my ($fh, $rbuf, $len) = @_;
         my $left = $len - length($$rbuf);
@@ -555,22 +551,6 @@ sub modified ($;$) {
         (split(/ /, <$fh> // time))[0] + 0; # integerize for JSON
 }
 
-# read_all/try_cat can probably be moved somewhere else...
-
-sub read_all ($;$$) {
-        my ($fh, $len, $bref) = @_;
-        $bref //= \(my $buf);
-        my $r = read($fh, $$bref, $len //= -s $fh);
-        croak("$fh read ($r != $len)") if $len != $r;
-        $$bref;
-}
-
-sub try_cat {
-        my ($path) = @_;
-        open(my $fh, '<', $path) or return '';
-        read_all($fh);
-}
-
 sub cat_desc ($) {
         my $desc = try_cat($_[0]);
         chomp $desc;