about summary refs log tree commit homepage
path: root/lib/PublicInbox/DS.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-04 12:15:45 +0000
committerEric Wong <e@80x24.org>2019-06-10 05:05:15 +0000
commit30ab5cf82b9d47242640f748a0f9a088ca783e32 (patch)
tree27e72894b5770b012d10d1a91ebcf4414aba237f /lib/PublicInbox/DS.pm
parent6fa2b29fcd0477d126ebb7db7f97b334f74bbcbc (diff)
downloadpublic-inbox-30ab5cf82b9d47242640f748a0f9a088ca783e32.tar.gz
ds: reduce Errno imports and drop ->close reason
ECONNRESET and EPIPE are common on a big Internet filled with
unreliable connections, and there's nothing our code can do
about it.

So no point in wasting code to log them and there are plenty of
tracing tools to choose from if such diagnostics are needed.
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r--lib/PublicInbox/DS.pm23
1 files changed, 5 insertions, 18 deletions
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 39f1922f..e2aa4b55 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -33,7 +33,7 @@ use fields ('sock',              # underlying socket
             'event_watch',       # bitmask of events the client is interested in (POLLIN,OUT,etc.)
             );
 
-use Errno  qw(EPIPE EAGAIN ECONNRESET EINVAL);
+use Errno  qw(EAGAIN EINVAL);
 use Carp   qw(croak confess);
 
 use constant DebugLevel => 0;
@@ -509,22 +509,15 @@ sub steal_socket {
     return $sock;
 }
 
-=head2 C<< $obj->close( [$reason] ) >>
+=head2 C<< $obj->close >>
 
-Close the socket. The I<reason> argument will be used in debugging messages.
+Close the socket.
 
 =cut
 sub close {
     my PublicInbox::DS $self = $_[0];
     return if $self->{closed};
 
-    # print out debugging info for this close
-    if (DebugLevel) {
-        my ($pkg, $filename, $line) = caller;
-        my $reason = $_[1] || "";
-        warn "Closing \#$self->{fd} due to $pkg/$filename/$line ($reason)\n";
-    }
-
     # this does most of the work of closing us
     $self->_cleanup();
 
@@ -655,9 +648,7 @@ sub write {
                                $self->{wbuf_off});
 
         if (! defined $written) {
-            if ($! == EPIPE) {
-                return $self->close("EPIPE");
-            } elsif ($! == EAGAIN) {
+            if ($! == EAGAIN) {
                 # since connection has stuff to write, it should now be
                 # interested in pending writes:
                 if ($need_queue) {
@@ -665,13 +656,9 @@ sub write {
                 }
                 $self->watch_write(1);
                 return 0;
-            } elsif ($! == ECONNRESET) {
-                return $self->close("ECONNRESET");
             }
 
-            DebugLevel >= 1 && $self->debugmsg("Closing connection ($self) due to write error: $!\n");
-
-            return $self->close("write_error");
+            return $self->close;
         } elsif ($written != $to_write) {
             DebugLevel >= 2 && $self->debugmsg("Wrote PARTIAL %d bytes to %d",
                                                $written, $self->{fd});