[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.
- [gnunet-scheme] 230/324: doc: Correct errors in ‘network structure’ section., (continued)
- [gnunet-scheme] 230/324: doc: Correct errors in ‘network structure’ section., gnunet, 2021/09/21
- [gnunet-scheme] 235/324: doc: Document how errors and received/sent messages are ordered., gnunet, 2021/09/21
- [gnunet-scheme] 199/324: guix: Use patched version of guile-fibers., gnunet, 2021/09/21
- [gnunet-scheme] 209/324: doc: Resolve the TODO about broken pipes., gnunet, 2021/09/21
- [gnunet-scheme] 213/324: nse/client: Use 'message-handler' macro., gnunet, 2021/09/21
- [gnunet-scheme] 222/324: mq-impl/stream: Handle closed ports more gracefully., gnunet, 2021/09/21
- [gnunet-scheme] 223/324: mq,doc: Update TODOs about message queues., gnunet, 2021/09/21
- [gnunet-scheme] 224/324: doc: Don't forget the message verifier., gnunet, 2021/09/21
- [gnunet-scheme] 225/324: mq: Inject errors when message verification has negative result., gnunet, 2021/09/21
- [gnunet-scheme] 234/324: doc: Remove resolved TODO., gnunet, 2021/09/21
- [gnunet-scheme] 240/324: mq-impl/stream: Handle ECONNRESET gracefully.,
gnunet <=
- [gnunet-scheme] 238/324: mq-impl/stream: Allow closing queues made with connect-fibers., gnunet, 2021/09/21
- [gnunet-scheme] 244/324: doc: Document the 'disconnected' callback., gnunet, 2021/09/21
- [gnunet-scheme] 246/324: mq,mq-impl: Remove TODOs about allocating memory., gnunet, 2021/09/21
- [gnunet-scheme] 245/324: mq-impl/stream: Eliminate 'return' argument of 'handle-input!'., gnunet, 2021/09/21
- [gnunet-scheme] 251/324: tests/utils: Move call-with-spawner from tests/mq-stream.scm., gnunet, 2021/09/21
- [gnunet-scheme] 221/324: mq-impl/stream: Delay knowing the port., gnunet, 2021/09/21
- [gnunet-scheme] 228/324: doc/fdl: Correct ‘quote’ typography., gnunet, 2021/09/21
- [gnunet-scheme] 231/324: doc: Document message verifiers., gnunet, 2021/09/21
- [gnunet-scheme] 236/324: mq-impl/stream: Close the port when stopping the fibers., gnunet, 2021/09/21
- [gnunet-scheme] 242/324: nse/client: Remove unused fields., gnunet, 2021/09/21