From 974b6c1ce11b224958f976ecab030a8c9bf5faf9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 9 Oct 2019 09:19:58 +0200 Subject: drop retry code, just fail and let the service restart --- systemd/udev-block-notify.service | 1 + udev-block-notify.c | 24 ++++-------------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/systemd/udev-block-notify.service b/systemd/udev-block-notify.service index f5062a5..31e27f8 100644 --- a/systemd/udev-block-notify.service +++ b/systemd/udev-block-notify.service @@ -8,6 +8,7 @@ ConditionUser=!@system [Service] Type=notify +Restart=on-failure ExecStart=/usr/bin/udev-block-notify [Install] diff --git a/udev-block-notify.c b/udev-block-notify.c index 0a87af1..34604af 100644 --- a/udev-block-notify.c +++ b/udev-block-notify.c @@ -88,7 +88,7 @@ int main (int argc, char ** argv) { struct notifications *notifications = NULL; unsigned int notification_timeout = NOTIFICATION_TIMEOUT; - int errcount = 0, i; + int i; dev_t devnum = 0; unsigned int major = 0, minor = 0; struct udev_device *dev = NULL; @@ -295,27 +295,11 @@ int main (int argc, char ** argv) { notify_notification_set_timeout(notification, notification_timeout); while(notify_notification_show(notification, &error) == FALSE) { - if (errcount > 1 || doexit) { - fprintf(stderr, "%s: Looks like we can not reconnect to notification daemon... Exiting.\n", program); - exit(EXIT_FAILURE); - } else { - g_printerr("%s: Error \"%s\" while trying to show notification. Trying to reconnect.\n", program, error->message); - errcount++; - - g_error_free(error); - error = NULL; - - notify_uninit(); + g_printerr("%s: Error showing notification: %s\n", program, error->message); + g_error_free(error); - usleep(500 * 1000); - - if(notify_init("Udev-Block-Notification") == FALSE) { - fprintf(stderr, "%s: Can't create notify.\n", program); - exit(EXIT_FAILURE); - } - } + exit(EXIT_FAILURE); } - errcount = 0; free(notifystr); udev_device_unref(dev); -- cgit v1.2.3-70-g09d2