[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 250/324: doc: Document that (gnu gnunet nse client) reco
From: |
gnunet |
Subject: |
[gnunet-scheme] 250/324: doc: Document that (gnu gnunet nse client) reconnects. |
Date: |
Tue, 21 Sep 2021 13:24:50 +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 1a0ff0a7d1a8aa0f16e9f3b75b38b73e6b037ff5
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Wed Sep 8 20:58:44 2021 +0200
doc: Document that (gnu gnunet nse client) reconnects.
* doc/scheme-gnunet.tm (Estimation of the size of the network):
Document that the module will retry after a disconnect.
---
doc/scheme-gnunet.tm | 6 +++--
gnu/gnunet/nse/client.scm | 8 +++++--
tests/network-size.scm | 56 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 4 deletions(-)
diff --git a/doc/scheme-gnunet.tm b/doc/scheme-gnunet.tm
index e454d2d..cc6d835 100644
--- a/doc/scheme-gnunet.tm
+++ b/doc/scheme-gnunet.tm
@@ -566,8 +566,10 @@
the latest available estimate.<space|1em>If the
<with|font-shape|italic|server object> doesn't have an estimate yet, that
procedure will return <scm|#false> instead of an estimate.<space|1em>When
- the connection is lost, the (optional) thunk <var|disconnected> is
- called.<space|1em><todo|reconnecting, disconnecting>
+ the connection is lost, the (optional) thunk <var|disconnected> is called
+ and <scm|(gnu gnunet nse client)> will retry connecting.
+
+ <todo|disconnecting>
The estimate object has a number of accessors:
diff --git a/gnu/gnunet/nse/client.scm b/gnu/gnunet/nse/client.scm
index a9072ef..f19f06c 100644
--- a/gnu/gnunet/nse/client.scm
+++ b/gnu/gnunet/nse/client.scm
@@ -116,7 +116,7 @@ timestamp."
;; See 'connect'.
(define* (reconnect estimate/box config #:key updated connected
disconnected
- (spawn spawn-fiber))
+ (spawn spawn-fiber) #:rest rest)
(define (handle-estimate! estimate-slice)
(define estimate
(%make-estimate
@@ -157,8 +157,12 @@ timestamp."
;; TODO this means the server has closed the connection ...
;; ---> reconnect?
((input:regular-end-of-file input:premature-end-of-file)
+ ;; Call 'reconnect' after 'disconnected'. Otherwise,
+ ;; it is possible that 'connected' is called twice without
+ ;; a call to 'disconnected' in-between, which would presumably
+ ;; be confusing.
(when disconnected (disconnected))
- (values))))
+ (apply reconnect estimate/box config rest))))
(define mq (connect/fibers config "nse" handlers error-handler
#:spawn spawn))
(signal-condition! mq-defined))
diff --git a/tests/network-size.scm b/tests/network-size.scm
index 69865cd..8ba03bb 100644
--- a/tests/network-size.scm
+++ b/tests/network-size.scm
@@ -31,6 +31,7 @@
(only (tests utils) call-with-services/fibers)
(only (fibers) sleep)
(gnu gnunet netstruct syntactic)
+ (ice-9 match)
(srfi srfi-1)
(srfi srfi-26)
(srfi srfi-43)
@@ -203,4 +204,59 @@
(sleep 0.001)
#t)))
+(define forever (make-condition))
+
+(test-assert "reconnects"
+ (let ((n 9)
+ (too-many? #f)
+ (done (make-condition)))
+ (call-with-services/fibers
+ `(("nse" . ,(lambda (port spawn-fiber)
+ (if (> n 0)
+ (begin
+ (set! n (- n 1))
+ (close-port port))
+ (wait forever)))))
+ (lambda (config spawn-fiber)
+ (define disconnected? #f)
+ (define connected? #f)
+ (define disconnect-count 0)
+ (define (connected)
+ (match (cons disconnected? connected?)
+ ((#t . #f)
+ (set! disconnected? #f)
+ (set! connected? #t)
+ (values))
+ ((#t . #t) (error "impossible"))
+ ((#f . #f)
+ (set! connected? #t)
+ (values)) ; first connect
+ ((#f . #t) (error "doubly connected"))))
+ (define (disconnected)
+ (match (cons connected? disconnected?)
+ ((#t . #f)
+ (set! connected? #f)
+ (set! disconnected? #t)
+ (set! disconnect-count (+ 1 disconnect-count))
+ (cond
+ ((= disconnect-count 9)
+ (signal-condition! done))
+ ((> disconnect-count 9)
+ (set! too-many? #t)
+ (error "too many disconnects")))
+ (values))
+ ((#t . #t) (error "impossible"))
+ ((#f . #f)
+ (error "disconnected before connecting"))
+ ((#f . #t)
+ (error "doubly disconnected"))))
+ (define server
+ (nse:connect config #:spawn spawn-fiber #:connected connected
+ #:disconnected disconnected))
+ (wait done)
+ (sleep 0.01)
+ (assert (not too-many?))
+ (assert connected?)
+ #t))))
+
(test-end "network-size")
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet-scheme] 221/324: mq-impl/stream: Delay knowing the port., (continued)
- [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
- [gnunet-scheme] 243/324: doc/scheme-gnunet.tm: Correct use of 'connected' and 'updated'., gnunet, 2021/09/21
- [gnunet-scheme] 237/324: mq-impl/stream: Allow closing the queue on request., gnunet, 2021/09/21
- [gnunet-scheme] 247/324: nse/client: Only call 'send-start!' after 'mq' has been defined., gnunet, 2021/09/21
- [gnunet-scheme] 248/324: tests/mq-stream: Add missing parenthesis., gnunet, 2021/09/21
- [gnunet-scheme] 249/324: nse/client: Prepare for auto-reconnecting., gnunet, 2021/09/21
- [gnunet-scheme] 250/324: doc: Document that (gnu gnunet nse client) reconnects.,
gnunet <=
- [gnunet-scheme] 253/324: nse/client: Correct type documentation of <server>., gnunet, 2021/09/21
- [gnunet-scheme] 254/324: doc: Document how to disconnect from the NSE server., gnunet, 2021/09/21
- [gnunet-scheme] 258/324: build: Install compiled Guile modules in appropriate location., gnunet, 2021/09/21
- [gnunet-scheme] 256/324: nse/client: Verify positivity of estimate., gnunet, 2021/09/21
- [gnunet-scheme] 257/324: git: Mark .scm as Scheme files for diffing purposes., gnunet, 2021/09/21
- [gnunet-scheme] 261/324: git: Ignore some files created by Emacs., gnunet, 2021/09/21
- [gnunet-scheme] 259/324: build: Install the HTML and PDF documentation., gnunet, 2021/09/21
- [gnunet-scheme] 266/324: build: Add (gnu extractor enum) to the makefile., gnunet, 2021/09/21
- [gnunet-scheme] 255/324: nse/client: Remove resolved TODO., gnunet, 2021/09/21
- [gnunet-scheme] 264/324: build: Use $< and $@ for PDF and HTML generation., gnunet, 2021/09/21