gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] 39/42: server: Add type checking.


From: gnunet
Subject: [gnunet-scheme] 39/42: server: Add type checking.
Date: Sat, 10 Sep 2022 19:08:32 +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 c49d527d0021e3e05db5019a3e0c417c31b4acb2
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sat Sep 10 18:58:28 2022 +0200

    server: Add type checking.
    
    Some type errors were encountered in the past, a little more
    information would have been helpful.
---
 gnu/gnunet/server.scm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/gnu/gnunet/server.scm b/gnu/gnunet/server.scm
index 88ff883..85e28c5 100644
--- a/gnu/gnunet/server.scm
+++ b/gnu/gnunet/server.scm
@@ -31,7 +31,8 @@
          loop:spawner loop:lost-and-found run-loop spawn-server-loop)
   (import (only (rnrs base)
                begin define cons case else apply values quote lambda
-               if error list let and append assert string? procedure?)
+               if error list let and append assert string? procedure?
+               list? symbol?)
          (only (rnrs records syntactic)
                define-record-type)
          (only (fibers)
@@ -49,7 +50,7 @@
                make-lost-and-found collect-lost-and-found-operation
                losable-lost-and-found lost-and-found?)
          (only (gnu gnunet mq)
-               close-queue!)
+               message-queue? close-queue!)
          (only (gnu gnunet mq error-reporting)
                report-error)
           (only (gnu gnunet mq-impl stream)
@@ -71,6 +72,8 @@ This sends a @var{message} to @var{control-channel} or waits 
for
 @var{terminal-condition} to be signalled, whichever happens first.
 If the message is sent, @code{#true} is returned.  Otherwise, if
 @var{terminal-condition} was signalled, return @code{#false} instead."
+      (assert (condition? terminal-condition))
+      (assert (channel? control-channel))
       (perform-operation
        (choice-operation
        ;; Nothing to do when the <server> is permanently disconnected,
@@ -163,6 +166,8 @@ this maybe-sends @code{disconnect!} to the control channel."
            (error 'disconnect! ; TODO: test
                   "wrong server object type"
                   (list name type? server))))
+      (assert (symbol? name)) ; XXX not sure which
+      (assert (procedure? type?))
       disconnect!)
 
     
@@ -215,6 +220,9 @@ this maybe-sends @code{disconnect!} to the control channel."
 @item reconnect!, by calling the thunk @var{k/reconnect} in tail position
 
 TODO: maybe 'lost'"
+      (assert (message-queue? mq))
+      (assert (condition? terminal-condition))
+      (assert (procedure? k/reconnect!))
       (match message
         (('oops! key . arguments)
         ;; Some unknown error, report it (report-error) and close
@@ -240,6 +248,7 @@ TODO: maybe 'lost'"
     ;; TODO: document, check types
     ;; state: <loop>
     (define (run-loop state . rest)
+      (assert (loop? state))
       (define handlers (apply (loop:message-handlers-maker state) state rest))
       (define error-handler
        (apply (loop:error-handler*-maker state) state rest))
@@ -268,6 +277,10 @@ TODO: maybe 'lost'"
     (define* (spawn-server-loop server #:key (make-loop make-loop)
                                (initial-extra-loop-arguments '())
                                (spawn spawn-fiber) #:allow-other-keys #:rest r)
+      (assert (server? server))
+      (assert (procedure? make-loop))
+      (assert (list? initial-extra-loop-arguments))
+      (assert (procedure? spawn))
       "[TODO] and return @var{server}"
       (define loop-arguments
        (append (list #:terminal-condition (server-terminal-condition server)

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