dm: rv_dm: Request platform reboot if VIP service has a resource leak 84/130484/8
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Fri, 19 May 2017 17:27:36 +0000 (19:27 +0200)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Wed, 31 May 2017 15:41:52 +0000 (17:41 +0200)
Change-Id: Ia6608b7939eadea4a5991f21af5b556277aff0d0
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
src/decision_makers/rv_dm.c

index 7e4ca5a08638c7b4fde6d9a76d2235e2c5d497b6..4e8a85c95c5a477ada68d75997a851f0d61e8e55 100644 (file)
@@ -23,6 +23,7 @@
 #include "action.h"
 #include "event_processor.h"
 #include "log.h"
+#include "service.h"
 
 #define MODULE_NAME "resource_violation_decision_maker"
 
@@ -33,6 +34,12 @@ static int rv_event_match(struct faultd_event_handler *handler,
        return faultd_event_is_of_type(ev, RESOURCE_VIOLATION_EVENT_ID);
 }
 
+/*
+ * This handles resource violation for all types of sevices
+ * but action to be executed depends on service type:
+ * - For VIP service we reboot the machine
+ * - For all other services we just restart the service itself
+ */
 static int rv_make_decision(struct faultd_event_handler *handler)
 {
        struct faultd_event *ev = nqueue_pop(&handler->event_queue,
@@ -40,7 +47,6 @@ static int rv_make_decision(struct faultd_event_handler *handler)
                                                                                 nq_node);
        struct resource_violation_event *rv_ev = to_resource_violation_event(ev);
        struct faultd_event *new_ev;
-       /* For now this is just hardcoded to restart the service */
        struct dm_event_data ev_data = {
                .reason = ev,
                .who_made = MODULE_NAME,
@@ -49,11 +55,16 @@ static int rv_make_decision(struct faultd_event_handler *handler)
        };
        int ret;
 
-       ev_data.action_data = strdup(rv_ev->service.dbus_path);
-       if (!ev_data.action_data) {
-               log_error("Unable to duplicate service name");
-               faultd_event_unref(ev);
-               return -ENOMEM;
+       if (systemd_service_is_of_type(&rv_ev->service, FAULTD_SERVICE_TYPE_VIP)) {
+               ev_data.action = FAULTD_ACTION_REBOOT_ID;
+               ev_data.action_data = NULL;
+       } else {
+               ev_data.action_data = strdup(rv_ev->service.dbus_path);
+               if (!ev_data.action_data) {
+                       log_error("Unable to duplicate service name");
+                       faultd_event_unref(ev);
+                       return -ENOMEM;
+               }
        }
 
        ret = faultd_event_create(DECISION_MADE_EVENT_ID, &ev_data, &new_ev);