libweston: allow double-loading modules
authorPekka Paalanen <pekka.paalanen@collabora.com>
Mon, 4 Nov 2019 12:07:51 +0000 (14:07 +0200)
committerDaniel Stone <daniel@fooishbar.org>
Thu, 21 Nov 2019 16:32:55 +0000 (16:32 +0000)
This is necessary for the test harness to be able to execute the compositor
multiple times in the same process. As we never unload opened modules, the
first compositor iteration will leave them all loaded and following compositor
iterations will then have them already loaded.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
libweston/compositor.c

index af0da062998031c3557a62d1b253d8615c92bdf1..72a2905e6da912dae334c84f7595218986d0bd8c 100644 (file)
@@ -7618,15 +7618,13 @@ weston_load_module(const char *name, const char *entrypoint)
        module = dlopen(path, RTLD_NOW | RTLD_NOLOAD);
        if (module) {
                weston_log("Module '%s' already loaded\n", path);
-               dlclose(module);
-               return NULL;
-       }
-
-       weston_log("Loading module '%s'\n", path);
-       module = dlopen(path, RTLD_NOW);
-       if (!module) {
-               weston_log("Failed to load module: %s\n", dlerror());
-               return NULL;
+       } else {
+               weston_log("Loading module '%s'\n", path);
+               module = dlopen(path, RTLD_NOW);
+               if (!module) {
+                       weston_log("Failed to load module: %s\n", dlerror());
+                       return NULL;
+               }
        }
 
        init = dlsym(module, entrypoint);