gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] branch master updated: dht/client: Resolve id->operation


From: gnunet
Subject: [gnunet-scheme] branch master updated: dht/client: Resolve id->operation-map races.
Date: Tue, 15 Feb 2022 11:48:13 +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.

The following commit(s) were added to refs/heads/master by this push:
     new d4f7ba4  dht/client: Resolve id->operation-map races.
d4f7ba4 is described below

commit d4f7ba47a0a08701dfa212be39638247509ab051
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Tue Feb 15 10:46:10 2022 +0000

    dht/client: Resolve id->operation-map races.
    
    * gnu/gnunet/dht/client.scm
      (reconnect)[id->operation-map]: Add a comment about concurrency.
      (reconnect)[error-handler]<connection:connected>: Move the
      resumption code into ...
      (reconnect)[control]<resend-old-operations!>: ... this new case.
      (reconnect)[control]<stop-search>: Remove resolved TODO.
---
 gnu/gnunet/dht/client.scm | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/gnu/gnunet/dht/client.scm b/gnu/gnunet/dht/client.scm
index a5be707..e6ccc9c 100644
--- a/gnu/gnunet/dht/client.scm
+++ b/gnu/gnunet/dht/client.scm
@@ -755,6 +755,9 @@ code automatically tries to reconnect, so @var{connected} 
can be called after
       ;; 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.
+      ;;
+      ;; To avoid races, 'id->operation-map' and 'old-id->operation-map'
+      ;; are only accessed from 'control'.
       (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
@@ -834,19 +837,9 @@ operation is cancelled, return @code{#false} instead."
        (case key
          ((connection:connected)
           (connected)
-          (wait mq-defined)
-          ;; Resume old requests.  Only get operations need to be submitted
-          ;; again.
-          ;;
-          ;; 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)
-                                    old-id->operation-map))
-          (hash-clear! old-id->operation-map)
+          ;; Tell 'control' to resume old requests.
+          (maybe-send-control-message!* terminal-condition control-channel
+                                        'resend-old-operations!)
           (values))
          ((input:regular-end-of-file input:premature-end-of-file)
           (disconnected)
@@ -903,7 +896,6 @@ operation is cancelled, return @code{#false} instead."
           (control))
          (('stop-search! get)
           ;; TODO: tests!
-          ;; TODO: racy!
           ;; TODO: cancel outstanding messages to the DHT services for this
           ;; get operation (including the request to start searching), if
           ;; any.
@@ -922,6 +914,22 @@ operation is cancelled, return @code{#false} instead."
          (#('request-search-result-iterator unique-id response-channel)
           (put-message response-channel (hashv-ref id->operation-map 
unique-id))
           ;; Continue!
+          (control))
+         (('resend-old-operations!)
+          ;; Restart old operations.  Only get operations need to be submitted
+          ;; again.
+          ;;
+          ;; 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)
+                                    old-id->operation-map))
+          ;; Free some memory.
+          (hash-clear! old-id->operation-map)
+          ;; Continue!
           (control))))
       ;; Start the main event loop.
       (spawn control))))

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