X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fconfig%2Fsession-config.c;h=d53ec0aa530ae88201932675c2bcb7e6b6dff719;hb=0d4bab5e4bd1654515ce754a3d9699cafe9b41b2;hp=743b5143893a4364cf5bf4f314e408102f77824d;hpb=d7b645e2c77977a8a83362f27094bf6d126f6fb8;p=lttng-tools.git diff --git a/src/common/config/session-config.c b/src/common/config/session-config.c index 743b51438..d53ec0aa5 100644 --- a/src/common/config/session-config.c +++ b/src/common/config/session-config.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -177,6 +178,9 @@ LTTNG_HIDDEN const char * const config_event_context_preemptible = "PREEMPTIBLE" LTTNG_HIDDEN const char * const config_event_context_need_reschedule = "NEED_RESCHEDULE"; LTTNG_HIDDEN const char * const config_event_context_migratable = "MIGRATABLE"; +/* Deprecated symbols */ +const char * const config_element_perf; + enum process_event_node_phase { CREATION = 0, ENABLE = 1, @@ -1607,6 +1611,7 @@ int process_event_node(xmlNodePtr event_node, struct lttng_handle *handle, goto end; } + free(filter_expression); filter_expression = strdup((char *) content); free(content); if (!filter_expression) { @@ -2390,7 +2395,7 @@ end: static int process_session_node(xmlNodePtr session_node, const char *session_name, - int override) + int overwrite) { int ret, started = -1, snapshot_mode = -1; uint64_t live_timer_interval = UINT64_MAX; @@ -2565,7 +2570,7 @@ domain_init_error: goto error; } - if (override) { + if (overwrite) { /* Destroy session if it exists */ ret = lttng_destroy_session((const char *) name); if (ret && ret != -LTTNG_ERR_SESS_NOT_FOUND) { @@ -2660,7 +2665,7 @@ valid: static int load_session_from_file(const char *path, const char *session_name, - struct session_config_validation_ctx *validation_ctx, int override) + struct session_config_validation_ctx *validation_ctx, int overwrite) { int ret, session_found = !session_name; xmlDocPtr doc = NULL; @@ -2702,7 +2707,7 @@ int load_session_from_file(const char *path, const char *session_name, session_node; session_node = xmlNextElementSibling(session_node)) { ret = process_session_node(session_node, - session_name, override); + session_name, overwrite); if (session_name && ret == 0) { /* Target session found and loaded */ session_found = 1; @@ -2736,7 +2741,7 @@ struct dirent *alloc_dirent(const char *path) static int load_session_from_path(const char *path, const char *session_name, - struct session_config_validation_ctx *validation_ctx, int override) + struct session_config_validation_ctx *validation_ctx, int overwrite) { int ret, session_found = !session_name; DIR *directory = NULL; @@ -2811,7 +2816,7 @@ int load_session_from_path(const char *path, const char *session_name, file_path[path_len + file_name_len] = '\0'; ret = load_session_from_file(file_path, session_name, - validation_ctx, override); + validation_ctx, overwrite); if (session_name && !ret) { session_found = 1; break; @@ -2822,7 +2827,7 @@ int load_session_from_path(const char *path, const char *session_name, free(file_path); } else { ret = load_session_from_file(path, session_name, - validation_ctx, override); + validation_ctx, overwrite); if (ret) { goto end; } else { @@ -2837,8 +2842,8 @@ end: } } - if (!session_found) { - ret = -LTTNG_ERR_LOAD_SESSION_NOENT; + if (session_found && !ret) { + ret = 0; } return ret; @@ -2880,9 +2885,10 @@ invalid: LTTNG_HIDDEN int config_load_session(const char *path, const char *session_name, - int override, unsigned int autoload) + int overwrite, unsigned int autoload) { int ret; + bool session_loaded = false; const char *path_ptr = NULL; struct session_config_validation_ctx validation_ctx = { 0 }; @@ -2933,7 +2939,7 @@ int config_load_session(const char *path, const char *session_name, } if (path_ptr) { ret = load_session_from_path(path_ptr, session_name, - &validation_ctx, override); + &validation_ctx, overwrite); if (ret && ret != -LTTNG_ERR_LOAD_SESSION_NOENT) { goto end; } @@ -2941,6 +2947,7 @@ int config_load_session(const char *path, const char *session_name, * Continue even if the session was found since we have to try * the system wide sessions. */ + session_loaded = true; } } @@ -2962,7 +2969,10 @@ int config_load_session(const char *path, const char *session_name, if (path_ptr) { ret = load_session_from_path(path_ptr, session_name, - &validation_ctx, override); + &validation_ctx, overwrite); + if (!ret) { + session_loaded = true; + } } } else { ret = access(path, F_OK); @@ -2984,7 +2994,7 @@ int config_load_session(const char *path, const char *session_name, } ret = load_session_from_path(path, session_name, - &validation_ctx, override); + &validation_ctx, overwrite); } end: fini_session_config_validation_ctx(&validation_ctx); @@ -2995,5 +3005,16 @@ end: */ ret = 0; } + + if (session_loaded && ret == -LTTNG_ERR_LOAD_SESSION_NOENT) { + /* A matching session was found in one of the search paths. */ + ret = 0; + } return ret; } + +static +void __attribute__((destructor)) session_config_exit(void) +{ + xmlCleanupParser(); +}