X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodule.c;h=a77aa736f5f372bb1557c0622ba480b6abf6b90a;hb=96cfe486b3d3bb3e42f7738cd0764a0838e00cba;hp=d207c0a7d016f367c73f148ad46d7abc26e21460;hpb=996acd9220aa2a8e2bb502cc95d140eb44c322de;p=lttv.git diff --git a/ltt/branches/poly/lttv/module.c b/ltt/branches/poly/lttv/module.c index d207c0a7..a77aa736 100644 --- a/ltt/branches/poly/lttv/module.c +++ b/ltt/branches/poly/lttv/module.c @@ -59,7 +59,7 @@ void lttv_module_path_add(const char *name) } -static LttvModuleInfo * +static LttvModule * module_load(const char *name, int argc, char **argv) { GModule *gm; @@ -69,6 +69,8 @@ module_load(const char *name, int argc, char **argv) int i; char *pathname; + + const char *module_name; LttvModuleInit init_function; @@ -76,7 +78,9 @@ module_load(const char *name, int argc, char **argv) for(i = 0 ; i < modulesPaths->len ; i++) { pathname = g_module_build_path(modulesPaths->pdata[i],name); - gm = g_module_open(pathname,0); + gm = g_module_open(pathname,G_MODULE_BIND_LAZY); + g_critical("loading module : %s", pathname); + g_critical("module error : %s", g_module_error()); g_free(pathname); if(gm != NULL) break; @@ -86,37 +90,37 @@ module_load(const char *name, int argc, char **argv) if(gm == NULL) { pathname = g_module_build_path(NULL,name); - gm = g_module_open(pathname,0); + gm = g_module_open(pathname,G_MODULE_BIND_LAZY); + g_critical("loading module : %s", pathname); g_free(pathname); } /* Module cannot be found */ - if(gm == NULL) return NULL; /* Check if the module was already opened using the hopefully canonical name returned by g_module_name. */ - pathname = g_module_name(gm); + module_name = g_module_name(gm); - m = g_hash_table_lookup(modules, pathname); + m = g_hash_table_lookup(modules, module_name); if(m == NULL) { /* Module loaded for the first time. Insert it in the table and call the init function if any. */ - m = g_new(LttvModule); + m = g_new(LttvModule, 1); m->module = gm; m->ref_count = 0; m->load_count = 0; m->dependents = g_ptr_array_new(); - g_hash_table_insert(modules, pathname, m); + g_hash_table_insert(modules, (gpointer)module_name, m); if(!g_module_symbol(gm, "init", (gpointer)&init_function)) { g_warning("module %s (%s) has no init function", name, pathname); } - else init_Function(m, argc, argv); + else init_function(m, argc, argv); } else { @@ -132,11 +136,10 @@ module_load(const char *name, int argc, char **argv) } -LttvModuleInfo * +LttvModule * lttv_module_load(const char *name, int argc, char **argv) { LttvModule *m = module_load(name, argc, argv); - if(m != NULL) m->load_count++; return m; } @@ -159,7 +162,7 @@ static void module_unload(LttvModule *m) char *pathname; - guint len; + guint i, len; /* Decrement the reference count */ @@ -261,7 +264,7 @@ lttv_module_unload_all() g_hash_table_foreach(modules, list_independent, independent_modules); for(i = 0 ; i < independent_modules->len ; i++) { - m = (LttvModule)independent_modules->pdata[i]; + m = (LttvModule *)independent_modules->pdata[i]; while(m->load_count > 0) lttv_module_unload(m); }