gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet-scheme] 240/324: mq-impl/stream: Handle ECONNRESET gracefully.


From: gnunet
Subject: [gnunet-scheme] 240/324: mq-impl/stream: Handle ECONNRESET gracefully.
Date: Tue, 21 Sep 2021 13:24:40 +0200

This is an automated email from the git hooks/post-receive script.

maxime-devos pushed a commit to branch master
in repository gnunet-scheme.

commit 125e7947f4db6b2386e3528148e8d7d0a63051f2
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Wed Sep 8 14:42:34 2021 +0200

    mq-impl/stream: Handle ECONNRESET gracefully.
    
    The otherwise failing test will be added in the next commit.
    
    * gnu/gnunet/mq-impl/stream.scm
      (handle-input!): Handle ECONNRESET with a input:regular-end-of-file
      error.
      (handle-input!)[return/thunked]: New procedure.
      (handle-input!)[return/overly-small,return/premature-eof,return/done-eof]:
      Thunk.
---
 gnu/gnunet/mq-impl/stream.scm | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/gnu/gnunet/mq-impl/stream.scm b/gnu/gnunet/mq-impl/stream.scm
index 72cd59c..df12cb6 100644
--- a/gnu/gnunet/mq-impl/stream.scm
+++ b/gnu/gnunet/mq-impl/stream.scm
@@ -75,7 +75,7 @@
          (only (guile)
                error define* identity define-values
                EACCES ENOENT ENOTDIR ELOOP ENAMETOOLONG EAGAIN ECONNREFUSED
-               EPROTOTYPE EPIPE
+               EPROTOTYPE EPIPE ECONNRESET
                PF_UNIX SOCK_STREAM F_GETFD F_SETFD F_GETFL F_SETFL FD_CLOEXEC
                O_NONBLOCK AF_UNIX
                socket connect fcntl force-output close-port
@@ -133,7 +133,8 @@ When the end-of-file has been reached, inject the error
 happened while inside a (partial) message, inject
 @code{input:premature-end-of-file} instead.
 
-In case of an I/O error, TODO.
+@code{ECONNRESET} is treated as @code{input:regular-end-of-file}.
+This might or might not be correct.  In case of an I/O error, TODO.
 
 In these exceptional cases, the call to this procedure also returns
 after injecting the error. TODO closing message queues."
@@ -144,14 +145,25 @@ after injecting the error. TODO closing message queues."
                 ;; TODO: this allocates memory
                 (slice/read-only
                  (bv-slice/read-write bv offset length))))
+            ;; Thunk the call to 'inject-error!' such that
+            ;; the exception handler is only active for the call to
+            ;; 'add-from-port!' and not for the call to 'inject-error!'.
+            (! (return/thunked . stuff)
+               (lambda () (apply return stuff)))
             (! (return/overly-small type size)
-               (return 'input:overly-small type size))
+               (return/thunked 'input:overly-small type size))
             (! (return/premature-eof)
-               (return 'input:premature-end-of-file))
+               (return/thunked 'input:premature-end-of-file))
             (! (return/done-eof)
-               (return 'input:regular-end-of-file)))
-           (add-from-port! tok input handle/message return/overly-small
-                           return/done-eof return/premature-eof)))
+               (return/thunked 'input:regular-end-of-file)))
+           ;; Prevent ‘In procedure fport_read: Connection reset by peer’
+           ;; in tests/network-size.scm.  XXX can this also happen in
+           ;; 'handle-output!'?
+           ((guard (c ((and (eq? 'system-error (exception-kind c))
+                            (= ECONNRESET (car (list-ref (exception-args c) 
3))))
+                       (return/done-eof)))
+              (add-from-port! tok input handle/message return/overly-small
+                              return/done-eof return/premature-eof)))))
 
     (define (handle-output! mq output wait!)
       "Keep sending message envelopes over the output port @var{output}.

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]