bug-guix
[Top][All Lists]
Advanced

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

bug#45314: ‘guix discover’ polls


From: Ludovic Courtès
Subject: bug#45314: ‘guix discover’ polls
Date: Fri, 18 Dec 2020 18:10:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Hi!

‘guix discover’ polls with 100ms intervals:

--8<---------------cut here---------------start------------->8---
18:00:57 poll([{fd=14, events=POLLIN}, {fd=16, events=POLLIN}], 2, 100) = 0 
(Timeout)
18:00:57 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
18:00:57 poll([{fd=14, events=POLLIN}, {fd=16, events=POLLIN}], 2, 100) = 0 
(Timeout)
18:00:57 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
18:00:57 poll([{fd=14, events=POLLIN}, {fd=16, events=POLLIN}], 2, 100) = 0 
(Timeout)
18:00:57 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
18:00:57 poll([{fd=14, events=POLLIN}, {fd=16, events=POLLIN}], 2, 100) = 0 
(Timeout)
18:00:57 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
18:00:57 poll([{fd=14, events=POLLIN}, {fd=16, events=POLLIN}], 2, 100) = 0 
(Timeout)
18:00:57 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
18:00:57 poll([{fd=14, events=POLLIN}, {fd=16, events=POLLIN}], 2, 100) = 0 
(Timeout)
18:00:57 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
18:00:57 poll([{fd=14, events=POLLIN}, {fd=16, events=POLLIN}], 2, 100) = 0 
(Timeout)
18:00:58 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
18:00:58 poll([{fd=14, events=POLLIN}, {fd=16, events=POLLIN}], 2, 100) = 0 
(Timeout)
--8<---------------cut here---------------end--------------->8---

This comes from ‘avahi-browse-service-thread’ in (guix avahi) and its
100ms #:timeout.

How about the change below?

Thanks,
Ludo’.

diff --git a/guix/avahi.scm b/guix/avahi.scm
index aa90a5cdd4..132e42f268 100644
--- a/guix/avahi.scm
+++ b/guix/avahi.scm
@@ -89,13 +89,19 @@ when STOP-LOOP? procedure returns true."
     (close-port socket)
     ip))
 
+(define never
+  ;; Never true.
+  (const #f))
+
 (define* (avahi-browse-service-thread proc
                                       #:key
                                       types
                                       (ignore-local? #t)
                                       (family AF_INET)
-                                      (stop-loop? (const #f))
-                                      (timeout 100))
+                                      (stop-loop? never)
+                                      (timeout (if (eq? stop-loop? never)
+                                                   #f
+                                                   100)))
   "Browse services which type is part of the TYPES list, using Avahi.  The
 search is restricted to services with the given FAMILY.  Each time a service
 is found or removed, PROC is called and passed as argument the corresponding
@@ -167,4 +173,6 @@ when STOP-LOOP? procedure returns true."
                               client-callback)))
     (and (client? client)
          (while (not (stop-loop?))
-           (iterate-simple-poll poll timeout)))))
+           (if timeout
+               (iterate-simple-poll poll timeout)
+               (iterate-simple-poll poll))))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]