about summary refs log tree commit homepage
path: root/lib/PublicInbox/ProcessPipe.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-02-28 11:28:33 +0000
committerEric Wong <e@80x24.org>2016-02-28 11:30:33 +0000
commit2ac2023fa416e31189708c355db8728abbd9ef2c (patch)
tree4d9eed94def3dfc7b6d7c0c5cb86bb734c84173c /lib/PublicInbox/ProcessPipe.pm
parent8f090c1ff5e4eea068f20b30f1f79144aae936a3 (diff)
downloadpublic-inbox-2ac2023fa416e31189708c355db8728abbd9ef2c.tar.gz
We can rely on timely auto-destruction based on reference
counting; reducing the chance of redundant close(2) calls
which may hit the wront FD.

We do care about certain close calls (e.g. writing to a buffered
IO handle) if we require error-checking for write-integrity.  In
other cases, let things go out-of-scope so it can be freed
automatically after use.
Diffstat (limited to 'lib/PublicInbox/ProcessPipe.pm')
-rw-r--r--lib/PublicInbox/ProcessPipe.pm5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/PublicInbox/ProcessPipe.pm b/lib/PublicInbox/ProcessPipe.pm
index eade524c..e088c105 100644
--- a/lib/PublicInbox/ProcessPipe.pm
+++ b/lib/PublicInbox/ProcessPipe.pm
@@ -15,13 +15,12 @@ sub READ { sysread($_[0]->{fh}, $_[1], $_[2], $_[3] || 0) }
 
 sub READLINE { readline($_[0]->{fh}) }
 
-sub CLOSE { close($_[0]->{fh}) }
+sub CLOSE { delete($_[0]->{fh}) }
 
 sub FILENO { fileno($_[0]->{fh}) }
 
 sub DESTROY {
-        my $fh = delete($_[0]->{fh});
-        close $fh if $fh;
+        delete($_[0]->{fh});
         waitpid($_[0]->{pid}, 0);
 }