unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48561: "Daemon not running" exception when avahi-daemon is not running
@ 2021-05-21  8:48 Maxime Devos
  2021-05-21 13:23 ` Mathieu Othacehe
  0 siblings, 1 reply; 4+ messages in thread
From: Maxime Devos @ 2021-05-21  8:48 UTC (permalink / raw)
  To: 48561

[-- Attachment #1: Type: text/plain, Size: 1472 bytes --]

Severity: minor

My /var/log/guix-daemon.log.* are full of backtraces like these
(and boring messages like SIGPOLL, spurious SIGPOLL, accepted connections
from pid [..], user [...]).

Backtrace:
In ice-9/boot-9.scm:
  1752:10 10 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
           9 (apply-smob/0 #<thunk 7f77d4149f60>)
In ice-9/boot-9.scm:
    724:2  8 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
    619:8  7 (_ #(#(#<directory (guile-user) 7f77d4143c80>)))
In guix/ui.scm:
  2166:12  6 (run-guix-command _ . _)
In ice-9/boot-9.scm:
  1752:10  5 (with-exception-handler _ _ #:unwind? _ # _)
  1747:15  4 (with-exception-handler #<procedure 7f77d0deeed0 at ic…> …)
In guix/scripts/discover.scm:
    141:8  3 (_)
In guix/avahi.scm:
   171:17  2 (avahi-browse-service-thread _ #:types _ #:ignore-local? …)
In unknown file:
           1 (make-client #<poll 7f77d0de41c0> () #<procedure client…>)
In ice-9/boot-9.scm:
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `avahi-error' with args `(#<avahi-error-enum Daemon not running> make-client)'.

Some kind of warning message when the daemon is not running makes sense,
but a full backtrace seems unneeded.

Maybe print a line like:

  warning: avahi daemon is not running, cannot auto-discover substitute servers!

instead.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#48561: "Daemon not running" exception when avahi-daemon is not running
  2021-05-21  8:48 bug#48561: "Daemon not running" exception when avahi-daemon is not running Maxime Devos
@ 2021-05-21 13:23 ` Mathieu Othacehe
  2021-05-21 14:37   ` Maxime Devos
  0 siblings, 1 reply; 4+ messages in thread
From: Mathieu Othacehe @ 2021-05-21 13:23 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 48561

[-- Attachment #1: Type: text/plain, Size: 164 bytes --]


Hello Maxime,

>   warning: avahi daemon is not running, cannot auto-discover substitute servers!

This should be fixed with the attached patch.

Thanks,

Mathieu

[-- Attachment #2: 0001-scripts-discover-Warn-when-the-daemon-is-unreachable.patch --]
[-- Type: text/x-patch, Size: 1930 bytes --]

From a50bbf99f65d26bbdb0d16112a49335bf913b822 Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <othacehe@gnu.org>
Date: Fri, 21 May 2021 15:21:15 +0200
Subject: [PATCH] scripts: discover: Warn when the daemon is unreachable.

* guix/scripts/discover (guix-discover): Print a warning message when the
daemon is unreachable.
---
 guix/scripts/discover.scm | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/guix/scripts/discover.scm b/guix/scripts/discover.scm
index be1eaa6e95..e42f7662d0 100644
--- a/guix/scripts/discover.scm
+++ b/guix/scripts/discover.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2020 Mathieu Othacehe <othacehe@gnu.org>
+;;; Copyright © 2020, 2021 Mathieu Othacehe <othacehe@gnu.org>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -26,6 +26,7 @@
   #:use-module (guix build syscalls)
   #:use-module (guix build utils)
   #:use-module (guix scripts publish)
+  #:use-module (avahi)
   #:use-module (ice-9 rdelim)
   #:use-module (srfi srfi-37)
   #:export (read-substitute-urls
@@ -138,5 +139,13 @@ to synchronize with the writer."
       (parameterize ((%publish-file publish-file))
         (mkdir-p (dirname publish-file))
         (false-if-exception (delete-file publish-file))
-        (avahi-browse-service-thread service-proc
-                                     #:types %services)))))
+        (catch 'avahi-error
+          (lambda ()
+            (avahi-browse-service-thread service-proc
+                                         #:types %services))
+          (lambda (key err function . _)
+            (cond
+             ((eq? err error/no-daemon)
+              (warning (G_ "Avahi daemon is not running, \
+cannot auto-discover substitutes servers.~%"))))
+            (exit 1)))))))
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#48561: "Daemon not running" exception when avahi-daemon is not running
  2021-05-21 13:23 ` Mathieu Othacehe
@ 2021-05-21 14:37   ` Maxime Devos
  2021-05-22 12:06     ` Mathieu Othacehe
  0 siblings, 1 reply; 4+ messages in thread
From: Maxime Devos @ 2021-05-21 14:37 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 48561

[-- Attachment #1: Type: text/plain, Size: 2177 bytes --]

Hi Mathieu,

Mathieu Othacehe schreef op vr 21-05-2021 om 15:23 [+0200]:
> +        (catch 'avahi-error
> +          (lambda ()
> +            (avahi-browse-service-thread service-proc
> +                                         #:types %services))
> +          (lambda (key err function . _)
> +            (cond
> +             ((eq? err error/no-daemon)
> +              (warning (G_ "Avahi daemon is not running, \
> +cannot auto-discover substitutes servers.~%"))))
> +            (exit 1)))))))

Shouldn't this code print an an error message when err is something
other than error/no-daemon?  You can use error->string. Two examples
from (guile-avahi)Error handling:

2.4 Error Handling
==================

Avahi errors are implemented as Scheme exceptions (*note exceptions in
Guile: (guile)Exceptions.).  Each time a Avahi function returns an
error, an exception with key 'avahi-error' is raised.  The additional
arguments that are thrown include an error code and the name of the
Avahi procedure that raised the exception.  The error code is pretty
much like an enumerate value: it is one of the 'error/' variables
exported by the '(avahi)' module (*note Enumerates and Constants::).
Exceptions can be turned into error messages using the 'error->string'
procedure.

   The following examples illustrates how Avahi exceptions can be
handled:

     (let ((poll (make-simple-poll)))

       ;;
       ;; ...
       ;;

       (catch 'avahi-error
         (lambda ()
           (run-simple-poll (simple-poll poll)))
         (lambda (key err function . currently-unused)
           (format (current-error-port)
                   "an Avahi error was raised by `~a': ~a~%"
                   function (error->string err)))))

   Again, error values can be compared using 'eq?':

         ;; `avahi-error' handler.
         (lambda (key err function . currently-unused)
           (if (eq? err error/no-daemon)
               (format (current-error-port)
                       "~a: the Avahi daemon is not running~%"
                       function)))

Otherwise LGTM, but I haven't tested.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#48561: "Daemon not running" exception when avahi-daemon is not running
  2021-05-21 14:37   ` Maxime Devos
@ 2021-05-22 12:06     ` Mathieu Othacehe
  0 siblings, 0 replies; 4+ messages in thread
From: Mathieu Othacehe @ 2021-05-22 12:06 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 48561-done


Hey,

> Otherwise LGTM, but I haven't tested.

Fixed with 7003b2db526fc367664f3a7c4bdbe38a7c717da6.

Thanks,

Mathieu




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-22 12:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21  8:48 bug#48561: "Daemon not running" exception when avahi-daemon is not running Maxime Devos
2021-05-21 13:23 ` Mathieu Othacehe
2021-05-21 14:37   ` Maxime Devos
2021-05-22 12:06     ` Mathieu Othacehe

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).