A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Let it work in SG (gras_init and gras_exit called only when needed)
[simgrid.git]
/
src
/
xbt
/
module.c
diff --git
a/src/xbt/module.c
b/src/xbt/module.c
index
f21cd23
..
c7b52bb
100644
(file)
--- a/
src/xbt/module.c
+++ b/
src/xbt/module.c
@@
-12,7
+12,8
@@
GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(module,GRAS);
GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(module,GRAS);
-extern void gras_log_finalize(void);
+extern void gras_log_exit(void);
+static int gras_running_process = 0;
struct gras_module_ {
gras_dynar_t *deps;
struct gras_module_ {
gras_dynar_t *deps;
@@
-22,38
+23,72
@@
struct gras_module_ {
gras_module_finalize_fct_t finalize;
};
gras_module_finalize_fct_t finalize;
};
+void
+gras_init(int *argc, char **argv) {
+ gras_init_defaultlog(argc, argv, NULL);
+}
/**
/**
- * gras_init:
+ * gras_init
_defaultlog
:
* @argc:
* @argv:
*
* Initialize the gras mecanisms.
*/
void
* @argc:
* @argv:
*
* Initialize the gras mecanisms.
*/
void
-gras_init
(int argc,char **argv
) {
- int i;
+gras_init
_defaultlog(int *argc,char **argv, const char *defaultlog
) {
+ int i
,j
;
char *opt;
gras_error_t errcode;
char *opt;
gras_error_t errcode;
+ int found=0;
INFO0("Initialize GRAS");
INFO0("Initialize GRAS");
- for (i=1; i<argc; i++) {
+
+ /** Set logs and init log submodule */
+ for (i=1; i<*argc; i++) {
if (!strncmp(argv[i],"--gras-log=",strlen("--gras-log="))) {
if (!strncmp(argv[i],"--gras-log=",strlen("--gras-log="))) {
+ found = 1;
opt=strchr(argv[i],'=');
opt++;
TRYFAIL(gras_log_control_set(opt));
opt=strchr(argv[i],'=');
opt++;
TRYFAIL(gras_log_control_set(opt));
+ DEBUG1("Did apply '%s' as log setting",opt);
+ /*remove this from argv*/
+ for (j=i+1; j<*argc; j++) {
+ argv[j-1] = argv[j];
+ }
+ argv[j-1] = NULL;
+ (*argc)--;
+ i--; /* compensate effect of next loop incrementation */
+ WARN1("argc %d",*argc);
}
}
}
}
+ if (!found && defaultlog) {
+ TRYFAIL(gras_log_control_set(defaultlog));
+ }
+
+ gras_process_init(); /* calls procdata_init, which calls dynar_new */
+ /** init other submodules */
+ if (gras_running_process++ == 0) {
+ gras_msg_init();
+ gras_trp_init();
+ gras_datadesc_init();
+ }
}
/**
}
/**
- * gras_finalize:
- * @argc:
- * @argv:
+ * gras_exit:
*
* Finalize the gras mecanisms.
*/
void
*
* Finalize the gras mecanisms.
*/
void
-gras_finalize(){
- gras_log_finalize();
+gras_exit(){
+ INFO0("Exiting GRAS");
+ gras_process_exit();
+ if (--gras_running_process == 0) {
+ gras_msg_exit();
+ gras_trp_exit();
+ gras_datadesc_exit();
+ }
+ gras_log_exit();
+ DEBUG0("Exited GRAS");
}
}