Load plugins with RTLD_GLOBAL, fixes Lua library exports
[project/uhttpd.git] / plugin.c
index cd4831e..b84236c 100644 (file)
--- a/plugin.c
+++ b/plugin.c
@@ -43,7 +43,7 @@ int uh_plugin_init(const char *name)
        const char *sym;
        void *dlh;
 
-       dlh = dlopen(name, RTLD_LAZY | RTLD_LOCAL);
+       dlh = dlopen(name, RTLD_LAZY | RTLD_GLOBAL);
        if (!dlh) {
                fprintf(stderr, "Could not open plugin %s: %s\n", name, dlerror());
                return -ENOENT;
@@ -65,5 +65,6 @@ void uh_plugin_post_init(void)
        struct uhttpd_plugin *p;
 
        list_for_each_entry(p, &plugins, list)
-               p->post_init();
+               if (p->post_init)
+                       p->post_init();
 }