gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] 02/05: dht/client: Make a distinction between old and ne


From: gnunet
Subject: [gnunet-scheme] 02/05: dht/client: Make a distinction between old and new operations.
Date: Tue, 15 Feb 2022 11:03:26 +0100

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 31776e595d24f6013012edc713b44f8cdadbfa1a
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Tue Feb 15 09:47:17 2022 +0000

    dht/client: Make a distinction between old and new operations.
    
    * gnu/gnunet/dht/client.scm
      (connect): Rename 'id->operation-map' to 'old-id->operation-map'.
      (reconnect): Likewise, and add a 'id->operation-map'
      variable. Adjust 'error-handler' and 'stop-search!' in 'control 'to
      use both.
---
 gnu/gnunet/dht/client.scm | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/gnu/gnunet/dht/client.scm b/gnu/gnunet/dht/client.scm
index a26022f..04fb95b 100644
--- a/gnu/gnunet/dht/client.scm
+++ b/gnu/gnunet/dht/client.scm
@@ -79,7 +79,7 @@
          (only (guile)
                pk define-syntax-rule define* lambda* error
                make-hash-table hashq-set! hashq-remove! hashv-set! hashv-ref
-               hash-map->list)
+               hashv-remove! hash-clear! hash-map->list)
          (only (ice-9 atomic)
                make-atomic-box atomic-box-ref atomic-box-set!)
          (only (ice-9 match)
@@ -733,10 +733,10 @@ when the connection has been made.  The connection can 
break; the optional thunk
 code automatically tries to reconnect, so @var{connected} can be called after
 @var{disconnected}.  This procedure returns a DHT server object."
       (define terminal-condition (make-condition))
-      (define id->operation-map (make-hash-table))
+      (define old-id->operation-map (make-hash-table))
       (define control-channel (make-channel))
       (reconnect terminal-condition config
-                id->operation-map control-channel
+                old-id->operation-map control-channel
                 #:connected connected
                 #:disconnected disconnected
                 #:spawn spawn)
@@ -746,10 +746,16 @@ code automatically tries to reconnect, so @var{connected} 
can be called after
 
     ;; TODO(id->operation-map): Hash tables are thread-unsafe.
     (define* (reconnect terminal-condition config
-                       id->operation-map control-channel
+                       old-id->operation-map control-channel
                        #:key (spawn spawn-fiber)
                        connected disconnected
                        #:rest rest)
+      ;; The 'id->operation-map' holds get operations that have
+      ;; been communicated to the service.  The 'old-id->operation-map'
+      ;; is used for reconnecting and holds get operations that need
+      ;; to be communicated to the service again.  'old-id->operation-map'
+      ;; only shrinks, while 'id->operation-map' can both grow and shrink.
+      (define id->operation-map (make-hash-table))
       (define (request-search-result-iterator unique-id)
        "Ask @code{control} what is the iterator for the get operation with
 unique id @var{unique-id}.  If there is no such get operation, or the get
@@ -834,11 +840,13 @@ operation is cancelled, return @code{#false} instead."
           ;;
           ;; TODO: restarting monitoring operations
           (for-each (lambda (get)
+                      (hashv-set! id->operation-map (get:unique-id get) get)
                       (send-get! mq get))
                     ;; XXX: @code{hash-for-each} forms a continuation barrier,
                     ;; so turn the hash table into a list before iterating.
                     (hash-map->list (lambda (x handle) handle)
-                                    id->operation-map))
+                                    old-id->operation-map))
+          (hash-clear! old-id->operation-map)
           (values))
          ((input:regular-end-of-file input:premature-end-of-file)
           (disconnected)
@@ -899,6 +907,7 @@ operation is cancelled, return @code{#false} instead."
           ;; TODO: cancel outstanding messages to the DHT services for this
           ;; get operation (including the request to start searching), if
           ;; any.
+          (hashv-remove! old-id->operation-map (get:unique-id get))
           (when (hashv-ref id->operation-map (get:unique-id get))
             (hashv-set! id->operation-map (get:unique-id get) #false)
             (send-stop-get! mq get)))

-- 
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]