lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sun, Oct 27, 2013 at 09:47:04PM +0100, Philipp Janda wrote:
> Am 27.10.2013 00:29 schröbte William Ahern:
> >
> >[...]
> >
> >One potential gotcha is that this breaks module unloading. Because the
> >second dlopen increments a reference count on the module, when Lua garbage
> >collects the module and calls dlclose there'll still be a reference. Most
> >people don't rely on module unloading, fortunately. Calling dlcose() on the
> >handle immediately after dlopen() might resolve this issue, but I haven't
> >tested it yet.
> >
> 
> You could try `RTLD_NOLOAD`. See here[1].
> 
>   [1]: http://comments.gmane.org/gmane.comp.lang.lua.general/102742.
> 

Unfortunately, RTLD_NOLOAD will still increment the reference count if
returning a handle. OS X documents this in their man page, and I just
confirmed with actual code on Linux.

I'm pretty sure simply calling dlclose again will work. But I can't even get
Linux to unload the library at all once a symbol has been retrieved via
global scoping (NULL handle), so it might just be a moot point. If you need
globally scoped bindings it'll never be unloadable, anyhow.