What is the best way to keep track of different signatures of shared objects?
- From: Ramon F Herrera <ramon@xxxxxxxxxxx>
- Date: Fri, 25 Sep 2009 22:08:48 -0700 (PDT)
This is the general scenario. My application is a server that loads a
large number of similar (i.e. same signature) shared objects at
startup time, to be used on-demand later.
Version 1 was simple in the sense that all the loadable modules had
the same signature. For fast access, I save the addresses of the *.so
files in a C++ map. This is the relevant code:
typedef bool (*address)(const char *, const char *, char *);
typedef map<string, address> module_address;
module_address addressOf;
bool (*function)(const char *, const char *, char *);
handle = dlopen((mod_dir + "/" + filename).c_str(), RTLD_NOW);
*(void **)(&function) = dlsym(handle, fnc_name);
if (function) {
addressOf[unique_id] = function;
roster[unique_id] = true;
}
So far, so good. I have loaded all the shared object files, and I know
how to execute each because I have kept their addresses in a handy
map.
Here comes the troublesome code, when I actually execute the
functions:
address function;
function = addressOf[unique_id];
if (!function) {
throw UNSUPPORTED_ID;
}
bool success = function(arg1, arg2, buffer);
The mentioned scheme works fine as long as I keep the same signature,
but alas, now I need to load and execute some new functions which need
more arguments:
bool success = function(arg1, arg2, buffer, extra_arg);
-Ramon
.
- Follow-Ups:
- Re: What is the best way to keep track of different signatures of shared objects?
- From: Ramon F Herrera
- Re: What is the best way to keep track of different signatures of shared objects?
- Prev by Date: Re: Open with... your online app
- Next by Date: Re: What is the best way to keep track of different signatures of shared objects?
- Previous by thread: ♀♂Nike AF1 Air Jordan Fusions wholesale♀♂Nike AF1 Air Jordan Fusions wholesale
- Next by thread: Re: What is the best way to keep track of different signatures of shared objects?
- Index(es):
Relevant Pages
|