gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] 154/324: mq: Implement 'inject-error!'.


From: gnunet
Subject: [gnunet-scheme] 154/324: mq: Implement 'inject-error!'.
Date: Tue, 21 Sep 2021 13:23:14 +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 75719b153f3de7059e48e71ff5032c695ee1dca1
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sat Jul 10 18:38:19 2021 +0200

    mq: Implement 'inject-error!'.
    
    It will be tested in the test suite of the ‘stream’ implementation
    of message queues.
    
    * README.org (List of errors): Document a few error codes
      to be used by the ‘stream’ implementation of message queues.
    * gnu/gnunet/mq.scm (inject-error!): New procedure.
---
 README.org        | 20 ++++++++++++++++++++
 gnu/gnunet/mq.scm | 17 ++++++++++++++---
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/README.org b/README.org
index ad11af7..757b965 100644
--- a/README.org
+++ b/README.org
@@ -93,6 +93,26 @@
    Message queue implementations based on streams I/O can use
    (gnu gnunet utils tokeniser), to split the message stream
    into separate messages.
+** List of errors
+
+   Not all errors indicate something is wrong.
+
+   Input errors
+   + input:regular-end-of-file
+
+     The end-of-file was encountered and not unexpected
+     (compare with input:premature-eof).
+   + input:premature-end-of-file
+
+     The end-of-file was encountered, but unexpected.
+     More specifically, a message was being read.
+   + input:overly-small type size
+
+     The message size in the header was smaller than the minimal
+     message size.
+
+   Input errors (decoding)
+   + TODO verification failed, unknown message type
 ** Configuration                                                  :test:good:
    + gnu/gnunet/config/parser.scm: Parse configuration files.
    + gnu/gnunet/config/expand.scm: Perform variable expansion.
diff --git a/gnu/gnunet/mq.scm b/gnu/gnunet/mq.scm
index af2a9fd..9851d04 100644
--- a/gnu/gnunet/mq.scm
+++ b/gnu/gnunet/mq.scm
@@ -32,7 +32,7 @@
 (define-library (gnu gnunet mq)
   (export <message-queue> make-message-queue message-queue?
          make-one-by-one-sender
-         inject-message! send-message!
+         inject-message! inject-error! send-message!
          message-queue-length
          %message-queue-garbagitude
          try-send-again!
@@ -69,7 +69,7 @@
                lambda assert let begin define
                procedure? eq? >= = <= < if quote
                values and let* not cons car cdr
-               cond + - > *)
+               cond + - > * apply)
          (only (rnrs control)
                when unless)
          (only (rnrs conditions)
@@ -118,7 +118,8 @@ handler is the ‘message type’.  Note that, unlike in the C 
implementation,
 messages are not serialised.  As such, some synchronisation or punting
 messages onto a separate thread may be necessary.
 
-XXX and error handler @var{error-handler}
+Injected errors are passed to @var{error-handler}, a variadic procedure.
+A list of possible errors can be found in @file{README.org}.
 
 Messages are sent with @var{sender}. It can be created with
 @code{make-one-by-one-sender}."
@@ -230,6 +231,16 @@ of message queues."
            ;; and stack overflow errors ...
            (handle-message! handler message)))
 
+    (define (inject-error! mq key . rest)
+      "Inject the error @code{key . rest} in the message queue @var{mq}.
+
+This is meant to be used by the message queue implementation,
+e.g. in response to an I/O error, although in principle it can be used by
+the user of the message queue as well.  Whether the message queue is still
+usable when this procedure is called, depends on the message queue
+implementation and injected error."
+      (apply (message-queue-error-handler mq) key rest))
+
     (define (message-queue-length mq)
       "How many messages are currently in the message queue @var{mq}?"
       (pfds:queue-length

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