X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Fmodule.c;h=bc4f3de0c941ad923c040345795d8818c6bc1616;hb=e05fc742955a6cef80d4e2ab88dd589bace6b6c8;hp=c2cc8fac72b1832979c45582b9c3114fe3ab2398;hpb=145c158877f87346395c76181529f709e146acc2;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/module.c b/ltt/branches/poly/lttv/lttv/module.c index c2cc8fac..bc4f3de0 100644 --- a/ltt/branches/poly/lttv/lttv/module.c +++ b/ltt/branches/poly/lttv/lttv/module.c @@ -20,6 +20,10 @@ /* module.c : Implementation of the module loading/unloading mechanism. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include @@ -70,7 +74,7 @@ static GQuark lttv_module_error; static void init(); -static finish_destroy(); +static void finish_destroy(); static void module_release(LttvModule *m); @@ -129,16 +133,17 @@ static void library_remove(LttvLibrary *l) LttvModule *m; GPtrArray *modules; - + GPtrArray **modules_ptr = &modules; /* for strict aliasing */ guint i; char *key; + char **key_ptr = &key; /* for strict aliasing */ for(i = 0 ; i < l->modules->len ; i++) { m = (LttvModule *)(l->modules->pdata[i]); g_hash_table_lookup_extended(modules_by_name, m->info.name, - (gpointer *)&key, (gpointer *)&modules); + (gpointer *)key_ptr, (gpointer *)modules_ptr); g_assert(modules != NULL); g_ptr_array_remove(modules, m); if(modules->len == 0) { @@ -162,11 +167,12 @@ static void library_remove(LttvLibrary *l) static LttvLibrary *library_load(char *name, GError **error) { - GModule *gm; + GModule *gm = NULL; int i, nb; - char *path, *pathname; + /* path is always initialized, checked */ + char *path = NULL, *pathname; LttvLibrary *l; @@ -234,7 +240,7 @@ LttvLibrary *lttv_library_load(char *name, GError **error) static void library_unload(LttvLibrary *l) { - guint i, len; + guint i; GModule *gm; @@ -522,7 +528,7 @@ static void init() } -static finish_destroy() +static void finish_destroy() { guint i; @@ -557,6 +563,7 @@ static void destroy() locked_libraries = g_new(LttvLibrary *, nb); for(i = 0 ; i < nb ; i++) { + //g_assert(nb == libraries->len); l = (LttvLibrary *)(libraries->pdata[i]); locked_libraries[i] = l; library_lock_loaded(l); @@ -564,7 +571,16 @@ static void destroy() m = (LttvModule *)(l->modules->pdata[j]); while(m->info.require_count > 0) lttv_module_release(m); } + library_unlock_loaded(l); while(l->info.load_count > 0) lttv_library_unload(l); + + /* If the number of librairies loaded have changed, restart from the + * beginning */ + if(nb != libraries->len) { + i = 0; + nb = libraries->len; + } + } for(i = 0 ; i < nb ; i++) {