[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 01/02: cadet/client: Keep track of channels.
From: |
gnunet |
Subject: |
[gnunet-scheme] 01/02: cadet/client: Keep track of channels. |
Date: |
Wed, 17 Aug 2022 17:20:08 +0200 |
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 e1bc644d78a2c403f6ca8d966e7dc7e96ff31c21
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Wed Aug 17 16:27:41 2022 +0200
cadet/client: Keep track of channels.
* gnu/gnunet/cadet/client.scm
(reconnect): Add argument 'channel-number->channel-hash-map' and add
some documentation.
(reconnect)[k/reconnect!]: Set new argument.
(connect): Likewise.
(reconnect)[control*]{open-channel!}: Add the channel to
'channel-number->channel-hash-map'.
(reconnect)[control*]{acknowledgement}: Look up the channel in the
hash map.
---
gnu/gnunet/cadet/client.scm | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/gnu/gnunet/cadet/client.scm b/gnu/gnunet/cadet/client.scm
index f2843b4..3fd7256 100644
--- a/gnu/gnunet/cadet/client.scm
+++ b/gnu/gnunet/cadet/client.scm
@@ -84,9 +84,12 @@
let^)
(only (rnrs base)
begin define lambda assert quote cons apply values
- case else = define-syntax + expt - let* let and >)
+ case else = define-syntax + expt - let* let and >
+ not)
(only (rnrs control)
unless)
+ (only (rnrs hashtables)
+ make-eqv-hashtable hashtable-ref hashtable-set!)
(only (rnrs records syntactic) define-record-type)
(only (ice-9 control) let/ec)
(only (ice-9 match) match)
@@ -145,16 +148,26 @@
(server-terminal-condition server)
(server-control-channel server)
connected disconnected spawn
- (losable-lost-and-found server))
+ (losable-lost-and-found server)
+ ;; integers cannot be compares with eq?,
+ ;; but they can be with eqv?
+ (make-eqv-hashtable))
server)
;; TODO: reduce duplication with (gnu gnunet dht client)
(define (spawn-procedure spawn . rest)
(spawn (lambda () (apply reconnect rest))))
+ ;; channel-number->channel-hash-map:
+ ;; A hash map from channel numbers to their corresponding
+ ;; <channel> object, or nothing if the control loop
+ ;; has not processes 'open-channel!' yet.
+ ;;
+ ;; TODO: GC problems, split in external and internal parts
(define (reconnect config terminal-condition control-channel
connected disconnected spawn
- lost-and-found)
+ lost-and-found
+ channel-number->channel-hash-map)
(define loop-operation
(choice-operation
(get-operation control-channel)
@@ -181,7 +194,8 @@
#:spawn spawn))
(define (k/reconnect!)
(reconnect config terminal-condition control-channel connected
- disconnected spawn lost-and-found))
+ disconnected spawn lost-and-found
+ channel-number->channel-hash-map))
(define (control next-free-channel-number)
"The main event loop."
(control* next-free-channel-number
@@ -237,6 +251,11 @@
;; TODO: handle overflow, and respect bounds
(next-free-channel-number (+ 1 next-free-channel-number)))
(set-channel-channel-number! channel channel-number)
+ ;; Keep track of the new <channel> object; it will be required
+ ;; later by 'acknowledgement'.
+ (hashtable-set! channel-number->channel-hash-map
+ channel-number
+ channel)
(send-local-channel-create! mq channel)
(control next-free-channel-number)))
(('close-channel! channel) TODO)
@@ -245,7 +264,12 @@
;; so for now nothing can be done.
(continue))
(('acknowledgement channel-number)
- TODO do stuff with channel-number)
+ (let^ ((! channel (hashtable-ref channel-number->channel-hash-map
+ channel-number
+ #false))
+ (? (not channel)
+ ???))
+ TODO do stuff with channel))
(('send-channel-stuff! message-queue channel)
;; Tell the service to send the messages over CADET.
(send-channel-stuff! channel)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.