I am trying to write a daemon that accesses non-reentrant libraries that are dynamically loaded. The job of these libraries is to go fetch and process data from various sources, then return the homogenized results when done. I'm multi-threading the application to hopefully speed up data requests by reducing wait time. The problem I'm having is trying to load the same reader library multiple times in the same process. When I use the dlopen on the library twice, it returns exactly the same handle the second time as the previous. I've attempted to use mmap on the file, but then I can't call dlsym. This makes sense, but that implies that I need to parse for various executable file formats (aout, coff, elf, etc.). Getting the file format isn't necessarily a problem, but is there a nice library created that I can just pass the memory that I've mapped to get the function pointers I need from the library? Or is there a more elegant solution? One idea I've been given is to create a temporary copy of the file, but that just seems kludgy. I'd really like a nice elegant solution.
Thanks. I know this isn't your typical 2 banana problem, so I've given the most the thing would allow me to submit it as.