avahi: Poll less.

* guix/avahi.scm (avahi-publish-service-thread): Have #:timeout default
to #f when 'stop-loop?' is NEVER, or 500ms.
(avahi-browse-service-thread): #:timeout defaults to 500ms when
'stop-loop?' is provided.
This commit is contained in:
Ludovic Courtès 2023-07-06 11:56:53 +02:00
parent ba1fe203b2
commit 0ae419877c
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5

View File

@ -49,11 +49,17 @@
(port avahi-service-port) (port avahi-service-port)
(txt avahi-service-txt)) (txt avahi-service-txt))
(define never
;; Never true.
(const #f))
(define* (avahi-publish-service-thread name (define* (avahi-publish-service-thread name
#:key #:key
type port type port
(stop-loop? (const #f)) (stop-loop? never)
(timeout 100) (timeout (if (eq? stop-loop? never)
#f
500))
(txt '())) (txt '()))
"Publish the service TYPE using Avahi, for the given PORT, on all interfaces "Publish the service TYPE using Avahi, for the given PORT, on all interfaces
and for all protocols. Also, advertise the given TXT record list. and for all protocols. Also, advertise the given TXT record list.
@ -89,10 +95,6 @@ when STOP-LOOP? procedure returns true."
(close-port socket) (close-port socket)
ip)) ip))
(define never
;; Never true.
(const #f))
(define* (avahi-browse-service-thread proc (define* (avahi-browse-service-thread proc
#:key #:key
types types
@ -101,7 +103,7 @@ when STOP-LOOP? procedure returns true."
(stop-loop? never) (stop-loop? never)
(timeout (if (eq? stop-loop? never) (timeout (if (eq? stop-loop? never)
#f #f
100))) 500)))
"Browse services which type is part of the TYPES list, using Avahi. The "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 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 is found or removed, PROC is called and passed as argument the corresponding