gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] 42/49: dht/client: Resolve race condition.


From: gnunet
Subject: [gnunet-scheme] 42/49: dht/client: Resolve race condition.
Date: Sat, 25 Dec 2021 23:00:19 +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 e6d9e0a8e8546a82d599696991a9837bbaa61cfe
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Thu Oct 7 08:03:38 2021 +0200

    dht/client: Resolve race condition.
    
    * gnu/gnunet/dht/client.scm (start-get!): Don't add the operation to
      the operation map.
      (connect)[process-new-get-operations]: Add the operation to the
      operation map.
---
 gnu/gnunet/dht/client.scm | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/gnu/gnunet/dht/client.scm b/gnu/gnunet/dht/client.scm
index dc00f09..7055458 100644
--- a/gnu/gnunet/dht/client.scm
+++ b/gnu/gnunet/dht/client.scm
@@ -225,13 +225,9 @@ might be reused."
                                desired-replication-level
                                (canonical-block-type type)
                                0)) ; TODO
-      ;; The operation must be added to id->operation-map before adding it
-      ;; to server-new-get-operations.  Otherwise, a concurrent start-get!
-      ;; could trigger new-get-operations-trigger between the hashv-set!
-      ;; and hashq-set!, possibly causing the operation to be sent
-      (hashv-set! (server-id->operation-map server) id handle)
-      (hashq-set! (server-new-get-operations server) handle #t) ; XXX race 
condition, a condition variable is needed here, to be waited upon later
-      ;; Asynchronuously process the new get request.
+      ;; Tell 'process-new-get-operations' about the new get operation.
+      ;; That fiber will take care of putting it into the operation map.
+      (hashq-set! (server-new-get-operations server) handle #t)
       (trigger-condition! (server-new-get-operation-trigger server))
       handle)
 
@@ -428,10 +424,14 @@ structure) to the get request @var{handle}."
 to the DHT service."
        (await-trigger! new-get-operation-trigger)
        (pk 'newstuff!)
-       ;; Extract the latest new operations
+       ;; Extract the latest new operations ...
        (define new (hash-map->list (lambda (get _) get) new-get-operations))
-       ;; And remove them from the hash table
-       (for-each (lambda (get) (hashq-remove! new-get-operations get)) new)
+       ;; remove them from the list of new operations and add them
+       ;; to the hash table of operations ...
+       (for-each (lambda (get)
+                   (hashq-remove! new-get-operations get)
+                   (hashq-set! id->operation-map (get:unique-id get) get))
+                 new)
        ;; and (asynchronuously) sent the GET message
        (for-each (lambda (get) (send-get! mq get)) new)
        ;; TODO reconnection, closing queues and cancelling get operations,

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