gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] 01/02: dht: Allow cancelling get operations.


From: gnunet
Subject: [gnunet-scheme] 01/02: dht: Allow cancelling get operations.
Date: Mon, 14 Feb 2022 22:01:05 +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 113fc6958a5f6b0ec5b341258c6a9e2f56b23862
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Mon Feb 14 20:57:50 2022 +0000

    dht: Allow cancelling get operations.
    
    TODO: untested! (except for examples/web.scm which seems to work)
    TODO: various edge cases.
    
    * gnu/gnunet/dht/client.scm (<server>): Add a TODO.
      (send-stop-get!,stop-get!): New procedures.
      (reconnect)[control]<stop-get>: New case.
---
 doc/distributed-hash-table.tm |  7 +++++++
 gnu/gnunet/dht/client.scm     | 25 ++++++++++++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/doc/distributed-hash-table.tm b/doc/distributed-hash-table.tm
index 46eb5db..784c804 100644
--- a/doc/distributed-hash-table.tm
+++ b/doc/distributed-hash-table.tm
@@ -156,6 +156,13 @@
     to make a copy of the search result, using <scm|copy-search-result>.
   </explain>
 
+  <\explain>
+    <scm|(stop-get! <var|search>)><index|stop-get!>
+  </explain|Cancel the get operation described by the search object
+  <var|search>. This is an asynchronuous operation; it does not have an
+  immediate effect. This is an idempotent operation: cancelling a search does
+  not have any additional effect.>
+
   <\explain>
     <scm|(put! <var|server> <var|insertion> <var|#:confirmed>)><index|put!>
   <|explain>
diff --git a/gnu/gnunet/dht/client.scm b/gnu/gnunet/dht/client.scm
index 2520bf6..8b74f43 100644
--- a/gnu/gnunet/dht/client.scm
+++ b/gnu/gnunet/dht/client.scm
@@ -581,7 +581,7 @@ currently unsupported."
              ;; Atomic box holding an unsigned 64-bit integer.
              (immutable next-unique-id/box server-next-unique-id/box)
              ;; Hash table from operation ids to their corresponding
-             ;; <get> object.
+             ;; <get> object.  TODO: hash maps are thread-unsafe
              (immutable id->operation-map server-id->operation-map)))
 
     (define (maybe-send-control-message!* terminal-condition control-channel
@@ -619,6 +619,13 @@ do anything if @var{server} has been permanently 
disconnected."
                                              (get:unique-id get)
                                              (get:options get))))
 
+    (define (send-stop-get! mq get)
+      "Send a message for stopping the get operation @var{get}."
+      (send-message!
+       mq
+       (construct-client-get-stop (query-key (get:query get))
+                                 (get:unique-id get))))
+
     (define (fresh-id server)
       "Generate a fresh numeric ID to use for communication with @var{server}."
       ;; Atomically increment the ‘next unique id’, but avoid
@@ -673,6 +680,13 @@ search result, using @lisp{copy-search-result}."
       (maybe-send-control-message! server 'start-get! handle)
       handle)
 
+    (define (stop-get! search)
+      "Cancel the get operation @var{search}.  This is an asynchronuous 
operation;
+it does not have an immediate effect.  This is an idempotent operation; 
cancelling
+a search twice does not have any additional effect."
+      (maybe-send-control-message! (get:server search) 'stop-get! get)
+      (values))
+
     (define* (put! server insertion #:key (confirmed values))
       "Perform the insertion @var{insertion}. When the datum has been inserted,
 the thunk @var{confirmed} is called. A @emph{put object} is returned which can
@@ -862,6 +876,15 @@ code automatically tries to reconnect, so @var{connected} 
can be called after
           (send-get! mq get)
           ;; Continue!
           (control))
+         (('stop-get! 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.
+          (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)))
          (('put! put)
           ;; Send the put operation to the DHT service.
           (send-message! mq (put:message put))

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