diff options
author | Christian Hesse <mail@eworm.de> | 2019-10-09 09:19:58 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2019-10-09 09:19:58 +0200 |
commit | 974b6c1ce11b224958f976ecab030a8c9bf5faf9 (patch) | |
tree | ae38c207c6efd44c06aaff8fafb03c3b64b1c2b2 | |
parent | 2962b4fb7fb06aa683005b5d2bdc7d69cc87e324 (diff) | |
download | udev-block-notify-974b6c1ce11b224958f976ecab030a8c9bf5faf9.tar.gz udev-block-notify-974b6c1ce11b224958f976ecab030a8c9bf5faf9.tar.zst |
drop retry code, just fail and let the service restart
-rw-r--r-- | systemd/udev-block-notify.service | 1 | ||||
-rw-r--r-- | 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); |