projects
/
lttv.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
git-svn-id: http://ltt.polymtl.ca/svn@307 04897980-b3bd-0310-b5e0-8ef037075253
[lttv.git]
/
ltt
/
branches
/
poly
/
lttv
/
module.c
diff --git
a/ltt/branches/poly/lttv/module.c
b/ltt/branches/poly/lttv/module.c
index 0f6f5a0727a0d35e8fddb7cc23a24a2db8b25fcb..7640f8655be263c6d23edcd5067597b431793128 100644
(file)
--- a/
ltt/branches/poly/lttv/module.c
+++ b/
ltt/branches/poly/lttv/module.c
@@
-5,6
+5,8
@@
#include <lttv/module.h>
#include <lttv/module.h>
+#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
+#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
struct _LttvModule
{
struct _LttvModule
{
@@
-26,6
+28,7
@@
static void lttv_module_unload_all();
void lttv_module_init(int argc, char **argv)
{
void lttv_module_init(int argc, char **argv)
{
+ g_info("Init module.c");
modules = g_hash_table_new(g_str_hash, g_str_equal);
modulesPaths = g_ptr_array_new();
}
modules = g_hash_table_new(g_str_hash, g_str_equal);
modulesPaths = g_ptr_array_new();
}
@@
-35,6
+38,8
@@
void lttv_module_destroy()
{
int i;
{
int i;
+ g_info("Destroy module.c");
+
/* Unload all modules */
lttv_module_unload_all();
/* Unload all modules */
lttv_module_unload_all();
@@
-55,6
+60,7
@@
void lttv_module_destroy()
void lttv_module_path_add(const char *name)
{
void lttv_module_path_add(const char *name)
{
+ g_info("Add module path %s", name);
g_ptr_array_add(modulesPaths,(char*)g_strdup(name));
}
g_ptr_array_add(modulesPaths,(char*)g_strdup(name));
}
@@
-74,27
+80,35
@@
module_load(const char *name, int argc, char **argv)
LttvModuleInit init_function;
LttvModuleInit init_function;
+ g_info("Load module %s", name);
+
/* Try to find the module along all the user specified paths */
for(i = 0 ; i < modulesPaths->len ; i++) {
pathname = g_module_build_path(modulesPaths->pdata[i],name);
/* Try to find the module along all the user specified paths */
for(i = 0 ; i < modulesPaths->len ; i++) {
pathname = g_module_build_path(modulesPaths->pdata[i],name);
+ g_info("Try path %s", pathname);
gm = g_module_open(pathname,0);
g_free(pathname);
if(gm != NULL) break;
gm = g_module_open(pathname,0);
g_free(pathname);
if(gm != NULL) break;
+ g_info("Trial failed, %s", g_module_error());
}
/* Try the default system path */
if(gm == NULL) {
pathname = g_module_build_path(NULL,name);
}
/* Try the default system path */
if(gm == NULL) {
pathname = g_module_build_path(NULL,name);
+ g_info("Try default path");
gm = g_module_open(pathname,0);
g_free(pathname);
}
/* Module cannot be found */
gm = g_module_open(pathname,0);
g_free(pathname);
}
/* Module cannot be found */
-
- if(gm == NULL) return NULL;
+ if(gm == NULL) {
+ g_info("Trial failed, %s", g_module_error());
+ g_info("Failed to load %s", name);
+ return NULL;
+ }
/* Check if the module was already opened using the hopefully canonical name
returned by g_module_name. */
/* Check if the module was already opened using the hopefully canonical name
returned by g_module_name. */
@@
-104,6
+118,7
@@
module_load(const char *name, int argc, char **argv)
m = g_hash_table_lookup(modules, module_name);
if(m == NULL) {
m = g_hash_table_lookup(modules, module_name);
if(m == NULL) {
+ g_info("Module %s (%s) loaded, call its init function", name, module_name);
/* Module loaded for the first time. Insert it in the table and call the
init function if any. */
/* Module loaded for the first time. Insert it in the table and call the
init function if any. */
@@
-118,13
+133,15
@@
module_load(const char *name, int argc, char **argv)
if(!g_module_symbol(gm, "init", (gpointer)&init_function)) {
g_warning("module %s (%s) has no init function", name, pathname);
}
if(!g_module_symbol(gm, "init", (gpointer)&init_function)) {
g_warning("module %s (%s) has no init function", name, pathname);
}
- else init_
F
unction(m, argc, argv);
+ else init_
f
unction(m, argc, argv);
}
else {
/* Module was already opened, check that it really is the same and
undo the extra g_module_open */
}
else {
/* Module was already opened, check that it really is the same and
undo the extra g_module_open */
+ g_info("Module %s (%s) was already loaded, no need to call init function",
+ name, module_name);
if(m->module != gm) g_error("Two gmodules with the same pathname");
g_module_close(gm);
}
if(m->module != gm) g_error("Two gmodules with the same pathname");
g_module_close(gm);
}
@@
-137,8
+154,8
@@
module_load(const char *name, int argc, char **argv)
LttvModule *
lttv_module_load(const char *name, int argc, char **argv)
{
LttvModule *
lttv_module_load(const char *name, int argc, char **argv)
{
+ g_info("Load module %s explicitly", name);
LttvModule *m = module_load(name, argc, argv);
LttvModule *m = module_load(name, argc, argv);
-
if(m != NULL) m->load_count++;
return m;
}
if(m != NULL) m->load_count++;
return m;
}
@@
-149,6
+166,8
@@
lttv_module_require(LttvModule *m, const char *name, int argc, char **argv)
{
LttvModule *module;
{
LttvModule *module;
+ g_info("Load module %s, as %s is a dependent requiring it", name,
+ g_module_name(m->module));
module = module_load(name, argc, argv);
if(module != NULL) g_ptr_array_add(m->dependents, module);
return module;
module = module_load(name, argc, argv);
if(module != NULL) g_ptr_array_add(m->dependents, module);
return module;
@@
-165,12
+184,16
@@
static void module_unload(LttvModule *m)
/* Decrement the reference count */
/* Decrement the reference count */
+ g_info("Unload module %s", g_module_name(m->module));
m->ref_count--;
m->ref_count--;
- if(m->ref_count > 0) return;
-
+ if(m->ref_count > 0) {
+ g_info("Module usage count decremented to %d", m->ref_count);
+ return;
+ }
/* We really have to unload the module, first unload its dependents */
len = m->dependents->len;
/* We really have to unload the module, first unload its dependents */
len = m->dependents->len;
+ g_info("Unload dependent modules");
for(i = 0 ; i < len ; i++) {
module_unload(m->dependents->pdata[i]);
for(i = 0 ; i < len ; i++) {
module_unload(m->dependents->pdata[i]);
@@
-180,6
+203,7
@@
static void module_unload(LttvModule *m)
/* Unload the module itself */
/* Unload the module itself */
+ g_info("Call the destroy function and unload the module");
if(!g_module_symbol(m->module, "destroy", (gpointer)&destroy_function)) {
g_warning("module (%s) has no destroy function", pathname);
}
if(!g_module_symbol(m->module, "destroy", (gpointer)&destroy_function)) {
g_warning("module (%s) has no destroy function", pathname);
}
@@
-194,6
+218,7
@@
static void module_unload(LttvModule *m)
void lttv_module_unload(LttvModule *m)
{
void lttv_module_unload(LttvModule *m)
{
+ g_info("Explicitly unload module %s", g_module_name(m->module));
if(m->load_count <= 0) {
g_error("more unload than load (%s)", g_module_name(m->module));
return;
if(m->load_count <= 0) {
g_error("more unload than load (%s)", g_module_name(m->module));
return;
@@
-241,6
+266,11
@@
lttv_module_info(LttvModule *m, const char **name,
return array;
}
return array;
}
+char *
+lttv_module_name(LttvModule *m)
+{
+ return g_module_name(m->module);
+}
static void
list_independent(gpointer key, gpointer value, gpointer user_data)
static void
list_independent(gpointer key, gpointer value, gpointer user_data)
This page took
0.024132 seconds
and
4
git commands to generate.