add mechanism for preventing unload of important modules during runtime
authorMike Blumenkrantz <zmike@osg.samsung.com>
Tue, 24 Nov 2015 20:26:10 +0000 (15:26 -0500)
committerMike Blumenkrantz <zmike@osg.samsung.com>
Tue, 24 Nov 2015 20:26:10 +0000 (15:26 -0500)
if a wayland output module is unloaded while the compositor is still
active, bad things will happen

src/bin/e_module.c

index ffae12ff404874a3dacc1c0437677035c0e30f00..c211b93b81f80e0ac6f9b0c29d952204ed763a02 100644 (file)
@@ -147,6 +147,27 @@ _module_is_nosave(const char *name)
    return !strncmp(name, "wl_", 3); //block wl_* modules from being saved
 }
 
+static Eina_Bool
+_module_is_important(const char *name)
+{
+   const char *list[] =
+   {
+      "xwayland",
+      "wl_desktop_shell",
+      "wl_drm",
+      "wl_fb",
+      "wl_text_input",
+      "wl_weekeyboard",
+      "wl_wl",
+      "wl_x11",
+   };
+   unsigned int i;
+
+   for (i = 0; i < EINA_C_ARRAY_LENGTH(list); i++)
+     if (eina_streq(name, list[i])) return EINA_TRUE;
+   return EINA_FALSE;
+}
+
 /* externally accessible functions */
 EINTERN int
 e_module_init(void)
@@ -535,6 +556,7 @@ e_module_disable(E_Module *m)
    E_OBJECT_CHECK_RETURN(m, 0);
    E_OBJECT_TYPE_CHECK_RETURN(m, E_MODULE_TYPE, 0);
    if ((!m->enabled) || (m->error)) return 0;
+   if ((!stopping) && _module_is_important(m->name)) return 0;
    ret = m->func.shutdown ? m->func.shutdown(m) : 1;
    m->data = NULL;
    m->enabled = 0;