Add notifier_device_ops for late or no booting done signal 24/199224/4 accepted/tizen/unified/20190208.061643 submit/tizen/20190207.112658
authorlokilee73 <changjoo.lee@samsung.com>
Thu, 7 Feb 2019 09:51:25 +0000 (18:51 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Thu, 7 Feb 2019 11:22:32 +0000 (11:22 +0000)
Systemd can't confirm booting done signal in valid time.
So, add notifier_device_ops to broadcast booting done siganl after 30 seconds,
if there is no booting done signal in it.

Change-Id: I535f8a848239b75fcd8e92f1ff13cd8ce895868a
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
src/core/device-notifier.c
src/core/device-notifier.h

index a88554c..369ac55 100644 (file)
@@ -21,6 +21,8 @@
 #include "device-notifier.h"
 #include "list.h"
 #include "common.h"
+#include "core/devices.h"
+#include <libgdbus/dbus-system.h>
 
 struct device_notifier {
        bool deleted;
@@ -30,7 +32,9 @@ struct device_notifier {
 
 static dd_list *device_notifier_list;
 static guint idl;
+static guint late_init_timer;
 
+#define LATE_INIT_TIME         30
 #define FIND_NOTIFIER(a, b, d, e, f) \
        DD_LIST_FOREACH(a, b, d) \
                if (e == d->e && f == (d->f))
@@ -135,3 +139,74 @@ void device_notify_once(enum device_notifier_type status, void *data)
        if (!idl)
                idl = g_idle_add(delete_unused_notifier_cb, NULL);
 }
+
+static void late_init_stop(void)
+{
+       if (!late_init_timer)
+               return;
+
+       g_source_remove(late_init_timer);
+       late_init_timer = 0;
+}
+
+static int booting_done(void *data)
+{
+       static int done;
+
+       if (data == NULL)
+               goto out;
+
+       done = *(int *)data;
+       if (!late_init_timer)
+               return done;
+       late_init_stop();
+
+out:
+       return done;
+}
+
+static gboolean late_init_timer_cb(void *data)
+{
+       int done;
+
+       late_init_stop();
+       done = booting_done(NULL);
+       if (done)
+               return G_SOURCE_REMOVE;
+       _I("late booting done");
+       done = TRUE;
+       device_notify_once(DEVICE_NOTIFIER_BOOTING_DONE, (void *)&done);
+
+       return G_SOURCE_REMOVE;
+}
+
+static void device_notifier_init(void *data)
+{
+       int ret;
+
+       ret = check_systemd_active();
+       if (ret == TRUE) {
+               _I("restart booting done");
+               return;
+       }
+       register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
+
+       late_init_timer = g_timeout_add_seconds(LATE_INIT_TIME,
+                               late_init_timer_cb, NULL);
+       if (!late_init_timer)
+               _E("Failed to set late_init_timer");
+}
+
+static void device_notifier_exit(void *data)
+{
+
+}
+
+static const struct device_ops notifier_device_ops = {
+       .name     = "notifier",
+       .init     = device_notifier_init,
+       .exit     = device_notifier_exit,
+};
+
+DEVICE_OPS_REGISTER(&notifier_device_ops)
+
index 087edb3..cb0ce1f 100644 (file)
@@ -85,5 +85,6 @@ typedef enum _device_notifier_state {
 int register_notifier(enum device_notifier_type status, int (*func)(void *data));
 int unregister_notifier(enum device_notifier_type status, int (*func)(void *data));
 void device_notify(enum device_notifier_type status, void *value);
+void device_notify_once(enum device_notifier_type status, void *data);
 
 #endif /* __DEVICE_NOTIFIER_H__ */