diff options
author | Maxime Devos <maximedevos@telenet.be> | 2021-09-08 14:42:34 +0200 |
---|---|---|
committer | Maxime Devos <maximedevos@telenet.be> | 2021-09-21 12:20:58 +0200 |
commit | 125e7947f4db6b2386e3528148e8d7d0a63051f2 (patch) | |
tree | 0f180f4036e6dfe00b66785431cca80a526d3afd /gnu | |
parent | d43f4efb370bace64ca79b41202615d8159bc3c7 (diff) | |
download | gnunet-scheme-125e7947f4db6b2386e3528148e8d7d0a63051f2.tar.gz gnunet-scheme-125e7947f4db6b2386e3528148e8d7d0a63051f2.zip |
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.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/gnunet/mq-impl/stream.scm | 26 |
1 files 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 @@ | |||
75 | (only (guile) | 75 | (only (guile) |
76 | error define* identity define-values | 76 | error define* identity define-values |
77 | EACCES ENOENT ENOTDIR ELOOP ENAMETOOLONG EAGAIN ECONNREFUSED | 77 | EACCES ENOENT ENOTDIR ELOOP ENAMETOOLONG EAGAIN ECONNREFUSED |
78 | EPROTOTYPE EPIPE | 78 | EPROTOTYPE EPIPE ECONNRESET |
79 | PF_UNIX SOCK_STREAM F_GETFD F_SETFD F_GETFL F_SETFL FD_CLOEXEC | 79 | PF_UNIX SOCK_STREAM F_GETFD F_SETFD F_GETFL F_SETFL FD_CLOEXEC |
80 | O_NONBLOCK AF_UNIX | 80 | O_NONBLOCK AF_UNIX |
81 | socket connect fcntl force-output close-port | 81 | socket connect fcntl force-output close-port |
@@ -133,7 +133,8 @@ When the end-of-file has been reached, inject the error | |||
133 | happened while inside a (partial) message, inject | 133 | happened while inside a (partial) message, inject |
134 | @code{input:premature-end-of-file} instead. | 134 | @code{input:premature-end-of-file} instead. |
135 | 135 | ||
136 | In case of an I/O error, TODO. | 136 | @code{ECONNRESET} is treated as @code{input:regular-end-of-file}. |
137 | This might or might not be correct. In case of an I/O error, TODO. | ||
137 | 138 | ||
138 | In these exceptional cases, the call to this procedure also returns | 139 | In these exceptional cases, the call to this procedure also returns |
139 | after injecting the error. TODO closing message queues." | 140 | after injecting the error. TODO closing message queues." |
@@ -144,14 +145,25 @@ after injecting the error. TODO closing message queues." | |||
144 | ;; TODO: this allocates memory | 145 | ;; TODO: this allocates memory |
145 | (slice/read-only | 146 | (slice/read-only |
146 | (bv-slice/read-write bv offset length)))) | 147 | (bv-slice/read-write bv offset length)))) |
148 | ;; Thunk the call to 'inject-error!' such that | ||
149 | ;; the exception handler is only active for the call to | ||
150 | ;; 'add-from-port!' and not for the call to 'inject-error!'. | ||
151 | (! (return/thunked . stuff) | ||
152 | (lambda () (apply return stuff))) | ||
147 | (! (return/overly-small type size) | 153 | (! (return/overly-small type size) |
148 | (return 'input:overly-small type size)) | 154 | (return/thunked 'input:overly-small type size)) |
149 | (! (return/premature-eof) | 155 | (! (return/premature-eof) |
150 | (return 'input:premature-end-of-file)) | 156 | (return/thunked 'input:premature-end-of-file)) |
151 | (! (return/done-eof) | 157 | (! (return/done-eof) |
152 | (return 'input:regular-end-of-file))) | 158 | (return/thunked 'input:regular-end-of-file))) |
153 | (add-from-port! tok input handle/message return/overly-small | 159 | ;; Prevent ‘In procedure fport_read: Connection reset by peer’ |
154 | return/done-eof return/premature-eof))) | 160 | ;; in tests/network-size.scm. XXX can this also happen in |
161 | ;; 'handle-output!'? | ||
162 | ((guard (c ((and (eq? 'system-error (exception-kind c)) | ||
163 | (= ECONNRESET (car (list-ref (exception-args c) 3)))) | ||
164 | (return/done-eof))) | ||
165 | (add-from-port! tok input handle/message return/overly-small | ||
166 | return/done-eof return/premature-eof))))) | ||
155 | 167 | ||
156 | (define (handle-output! mq output wait!) | 168 | (define (handle-output! mq output wait!) |
157 | "Keep sending message envelopes over the output port @var{output}. | 169 | "Keep sending message envelopes over the output port @var{output}. |