[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.
- [gnunet-scheme] 28/49: dht/client: Copy the key into the put message., (continued)
- [gnunet-scheme] 28/49: dht/client: Copy the key into the put message., gnunet, 2021/12/25
- [gnunet-scheme] 29/49: guix: Add guile-gcrypt., gnunet, 2021/12/25
- [gnunet-scheme] 44/49: guix: Skip tests in guile package., gnunet, 2021/12/25
- [gnunet-scheme] 37/49: examples/web: Correct destination of search form., gnunet, 2021/12/25
- [gnunet-scheme] 30/49: doc: Remove URLs., gnunet, 2021/12/25
- [gnunet-scheme] 39/49: examples/web: Dissect search result., gnunet, 2021/12/25
- [gnunet-scheme] 21/49: examples/web: Respond with HTML., gnunet, 2021/12/25
- [gnunet-scheme] 31/49: doc: Document dependency on Guile-Gcrypt., gnunet, 2021/12/25
- [gnunet-scheme] 41/49: dht/client: Impose some bounds on the replication level., gnunet, 2021/12/25
- [gnunet-scheme] 36/49: examples/web: License as AGPL., gnunet, 2021/12/25
- [gnunet-scheme] 42/49: dht/client: Resolve race condition.,
gnunet <=
- [gnunet-scheme] 48/49: examples/web (search-dht): Fail gracefully in case of invalid input, gnunet, 2021/12/25