From ef038c81dc420f137e95d91c5bf1a1f13924b168 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 9 Oct 2019 09:12:58 +0200 Subject: drop retry code, just fail and let the service restart --- netlink-notify.c | 23 +++-------------------- systemd/netlink-notify.service | 1 + 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/netlink-notify.c b/netlink-notify.c index 4a3b373..2fc5ac7 100644 --- a/netlink-notify.c +++ b/netlink-notify.c @@ -259,7 +259,6 @@ out: int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) { int rc = EXIT_FAILURE; char *notifystr = NULL; - unsigned int errcount = 0; GError *error = NULL; struct ifaddrmsg *ifa; struct ifinfomsg *ifi; @@ -456,25 +455,10 @@ int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) { notify_notification_update(notification, TEXT_TOPIC, notifystr, icon); 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); - goto out; - } 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(); - - usleep (500 * 1000); + g_printerr("%s: Error showing notification: %s\n", program, error->message); + g_error_free(error); - if (notify_init(PROGNAME) == FALSE) { - fprintf(stderr, "%s: Can't create notify.\n", program); - goto out; - } - } + goto out; } rc = EXIT_SUCCESS; @@ -482,7 +466,6 @@ int msg_handler (struct sockaddr_nl *nl, struct nlmsghdr *msg) { out: if (tmp_notification) g_object_unref(G_OBJECT(tmp_notification)); - errcount = 0; free(notifystr); return rc; diff --git a/systemd/netlink-notify.service b/systemd/netlink-notify.service index 863e8e7..a0a8c11 100644 --- a/systemd/netlink-notify.service +++ b/systemd/netlink-notify.service @@ -8,6 +8,7 @@ ConditionUser=!@system [Service] Type=notify +Restart=on-failure ExecStart=/usr/bin/netlink-notify [Install] -- cgit v1.2.3-70-g09d2