gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] 271/324: tests: Abstract setting of O_NONBLOCK.


From: gnunet
Subject: [gnunet-scheme] 271/324: tests: Abstract setting of O_NONBLOCK.
Date: Tue, 21 Sep 2021 13:25:11 +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 0de0dc6a36c988c79ce4f5be43a57f61e65c1e99
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sun Sep 12 15:59:41 2021 +0200

    tests: Abstract setting of O_NONBLOCK.
    
    * tests/utils.scm
      (make-nonblocking!): New procedure.
    * tests/mq-stream.scm
      ("port->message-queue, can send/receive between pairs")
      (two-sockets)
      ("can close after being connected (--> regular-end-of-file)"): Use it.
---
 tests/mq-stream.scm | 15 +++++----------
 tests/utils.scm     | 10 +++++++---
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/tests/mq-stream.scm b/tests/mq-stream.scm
index 84522b2..4a3793d 100644
--- a/tests/mq-stream.scm
+++ b/tests/mq-stream.scm
@@ -430,10 +430,8 @@
      ;; the first.
      (define pair (socketpair AF_UNIX SOCK_STREAM 0))
      ;; As 'fibers' is used instead of POSIX threads, set O_NONBLOCK.
-     (fcntl (car pair) F_SETFL
-           (bitwise-ior (fcntl (car pair) F_GETFL) O_NONBLOCK))
-     (fcntl (cdr pair) F_SETFL
-           (bitwise-ior (fcntl (cdr pair) F_GETFL) O_NONBLOCK))
+     (make-nonblocking! (car pair))
+     (make-nonblocking! (cdr pair))
      (define received/0 #f)
      (define received/1 #f)
      (define done/0 (make-condition))
@@ -465,10 +463,8 @@
 
 (define (two-sockets)
   (define sp (socketpair AF_UNIX SOCK_STREAM 0))
-  (fcntl (car sp) F_SETFL
-        (bitwise-ior (fcntl (car sp) F_GETFL) O_NONBLOCK))
-  (fcntl (cdr sp) F_SETFL
-        (bitwise-ior (fcntl (cdr sp) F_GETFL) O_NONBLOCK))
+  (make-nonblocking! (car sp))
+  (make-nonblocking! (cdr sp))
   (values (car sp) (cdr sp)))
 
 (test-assert "input eof detected --> handle-input/output! stops 
(port->message-queue)"
@@ -779,8 +775,7 @@ If an EPIPE system error is raised, return #f."
           (bind listening-sock AF_UNIX where)
           (listen listening-sock 1)
           ;; Make it non-blocking (because guile-fibers is used)
-          (fcntl listening-sock F_SETFL
-                 (bitwise-ior (fcntl listening-sock F_GETFL) O_NONBLOCK))
+          (make-nonblocking! listening-sock)
           ;; Not actually interested in the return value
           (accept listening-sock)))
        (wait connected-condition)
diff --git a/tests/utils.scm b/tests/utils.scm
index 3bde3c9..220fb96 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -31,7 +31,12 @@
                             call-with-services/fibers
                             call-with-spawner
                             call-with-spawner/wait
-                            call-with-temporary-directory))
+                            call-with-temporary-directory
+                            make-nonblocking!))
+
+(define (make-nonblocking! sock)
+  (fcntl sock F_SETFL
+        (bitwise-ior (fcntl sock F_GETFL) O_NONBLOCK)))
 
 ;; Current versions of guile (at least 3.0.5) use a conservative
 ;; garbage collector, so some tests concerning garbage collection
@@ -113,8 +118,7 @@ the services and each tails is a list of a procedure 
accepting ports
          (define sock (socket AF_UNIX SOCK_STREAM 0))
          (bind sock AF_UNIX where)
          (listen sock 40)
-         (fcntl sock F_SETFL
-                (bitwise-ior (fcntl sock F_GETFL) O_NONBLOCK))
+         (make-nonblocking! sock)
          (let loop ()
            (define client-sock
              (car (accept sock (logior SOCK_NONBLOCK

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