casaroli commented on code in PR #19639:
URL: https://github.com/apache/nuttx/pull/19639#discussion_r3712117092
##########
libs/libc/dlfcn/lib_dlclose.c:
##########
@@ -93,6 +95,22 @@ int dlclose(FAR void *handle)
* dlremove() is essentially a clone of rmmod().
*/
+ /* Remove only once the last handle has been closed. Under the registry
+ * lock for the same reason dlopen() counts under it; recursive, so
+ * libelf_remove() taking it again is fine.
+ */
+
+ libelf_registry_lock();
+
+ if (modp->nopen > 1)
Review Comment:
Done.
Reference counting now lives in `libelf_insert()`/`libelf_remove()`, so
`dlopen()`/`dlclose()` and `insmod()`/`rmmod()` all reach it through the same
code. `insmod()` still returns `EEXIST` on a duplicate name, so it checks
`libelf_gethandle()` before calling `libelf_insert()`
Verified on hardware (Pimoroni Pico Plus 2, RP2350/Cortex-M33): xipfs_test
fdpic 34/34, including two modules sharing one `DT_NEEDED` library through
`dlopen()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]