user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/9] ds: reduce Errno imports and drop ->close reason
Date: Mon, 10 Jun 2019 05:18:40 +0000	[thread overview]
Message-ID: <20190610051846.26757-4-e@80x24.org> (raw)
In-Reply-To: <20190610051846.26757-1-e@80x24.org>

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.
---
 lib/PublicInbox/DS.pm | 23 +++++------------------
 1 file 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});
-- 
EW


  parent reply	other threads:[~2019-06-10  5:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-10  5:18 [PATCH 0/9] ds: Diet Socket Eric Wong
2019-06-10  5:18 ` [PATCH 1/9] ds: simplify write buffer accounting Eric Wong
2019-06-10  5:18 ` [PATCH 2/9] ds: cleanup Errno imports and favor constant comparisons Eric Wong
2019-06-10  5:18 ` Eric Wong [this message]
2019-06-10  5:18 ` [PATCH 4/9] ds: remove {fd} field Eric Wong
2019-06-10  5:18 ` [PATCH 5/9] ds: remove steal_socket method Eric Wong
2019-06-10  5:18 ` [PATCH 6/9] nntp: use sysread to append to existing buffer Eric Wong
2019-06-10  5:18 ` [PATCH 7/9] ds: remove read method, here, too Eric Wong
2019-06-10  5:18 ` [PATCH 8/9] ds: do not distinguish between POLLHUP and POLLERR Eric Wong
2019-06-10  5:18 ` [PATCH 9/9] ds: stop caring about event flags set by epoll/poll/kqueue Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190610051846.26757-4-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).