X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Fload.c;h=0bebdc094514cdd48d651a6f666b006dfe1cc8d2;hb=1b08cbce538eedab5682d174c012903d128c216f;hp=be236f242b25b9fb0096ba42e73167d6400fb38b;hpb=0d4bab5e4bd1654515ce754a3d9699cafe9b41b2;p=lttng-tools.git diff --git a/src/lib/lttng-ctl/load.c b/src/lib/lttng-ctl/load.c index be236f242..0bebdc094 100644 --- a/src/lib/lttng-ctl/load.c +++ b/src/lib/lttng-ctl/load.c @@ -43,15 +43,18 @@ void reset_load_session_attr_urls(struct lttng_load_session_attr *attr) free(attr->raw_override_path_url); free(attr->raw_override_ctrl_url); free(attr->raw_override_data_url); - free(attr->override_attr.path_url); - free(attr->override_attr.ctrl_url); - free(attr->override_attr.data_url); + if (attr->override_attr) { + free(attr->override_attr->path_url); + free(attr->override_attr->ctrl_url); + free(attr->override_attr->data_url); + } } void lttng_load_session_attr_destroy(struct lttng_load_session_attr *attr) { if (attr) { reset_load_session_attr_urls(attr); + free(attr->override_attr); free(attr); } } @@ -91,7 +94,7 @@ const char *lttng_load_session_attr_get_override_path_url( { const char *ret = NULL; - if (attr && attr->override_attr.path_url) { + if (attr && attr->override_attr->path_url) { ret = attr->raw_override_path_url; } @@ -103,7 +106,7 @@ const char *lttng_load_session_attr_get_override_ctrl_url( { const char *ret = NULL; - if (attr && attr->override_attr.ctrl_url) { + if (attr && attr->override_attr->ctrl_url) { ret = attr->raw_override_ctrl_url; } @@ -115,7 +118,7 @@ const char *lttng_load_session_attr_get_override_data_url( { const char *ret = NULL; - if (attr && attr->override_attr.data_url) { + if (attr && attr->override_attr->data_url) { ret = attr->raw_override_data_url; } @@ -127,9 +130,9 @@ const char *lttng_load_session_attr_get_override_url( { const char *ret = NULL; - if (attr && (attr->override_attr.path_url || - (attr->override_attr.ctrl_url && - attr->override_attr.data_url))) { + if (attr && (attr->override_attr->path_url || + (attr->override_attr->ctrl_url && + attr->override_attr->data_url))) { ret = attr->raw_override_url; } @@ -233,12 +236,19 @@ int lttng_load_session_attr_set_override_ctrl_url( goto end; } - if (attr->override_attr.path_url) { + if (!attr->override_attr) { + attr->override_attr = zmalloc( + sizeof(struct config_load_session_override_attr)); + if (!attr->override_attr) { + ret = -LTTNG_ERR_NOMEM; + goto end; + } + } + + if (attr->override_attr->path_url) { /* - * FIXME: return a more meaningful error. - * Setting a ctrl override after a path override make no - * sense. - * */ + * Setting a ctrl override after a path override makes no sense. + */ ret = -LTTNG_ERR_INVALID; goto end; } @@ -279,11 +289,11 @@ int lttng_load_session_attr_set_override_ctrl_url( } /* Squash old value if any */ - free(attr->override_attr.ctrl_url); + free(attr->override_attr->ctrl_url); free(attr->raw_override_ctrl_url); /* Populate the object */ - attr->override_attr.ctrl_url = url_str; + attr->override_attr->ctrl_url = url_str; attr->raw_override_ctrl_url = raw_str; /* Ownership passed to attr. */ @@ -311,7 +321,19 @@ int lttng_load_session_attr_set_override_data_url( goto end; } - if (attr->override_attr.path_url) { + if (!attr->override_attr) { + attr->override_attr = zmalloc( + sizeof(struct config_load_session_override_attr)); + if (!attr->override_attr) { + ret = -LTTNG_ERR_NOMEM; + goto end; + } + } + + if (attr->override_attr->path_url) { + /* + * Setting a data override after a path override makes no sense. + */ ret = -LTTNG_ERR_INVALID; goto end; } @@ -351,11 +373,11 @@ int lttng_load_session_attr_set_override_data_url( } /* Squash old value if any */ - free(attr->override_attr.data_url); + free(attr->override_attr->data_url); free(attr->raw_override_data_url); /* Populate the object */ - attr->override_attr.data_url = url_str; + attr->override_attr->data_url = url_str; attr->raw_override_data_url = raw_str; /* Ownership passed to attr. */ @@ -388,6 +410,15 @@ int lttng_load_session_attr_set_override_url( goto end; } + if (!attr->override_attr) { + attr->override_attr = zmalloc( + sizeof(struct config_load_session_override_attr)); + if (!attr->override_attr) { + ret = -LTTNG_ERR_NOMEM; + goto end; + } + } + /* * FIXME: uri_parse should be able to take as parameter the protocol * type to validate "url". For now only check the parsing goes through; @@ -475,9 +506,9 @@ int lttng_load_session_attr_set_override_url( reset_load_session_attr_urls(attr); - attr->override_attr.path_url = path_str; - attr->override_attr.ctrl_url = ctrl_str; - attr->override_attr.data_url = data_str; + attr->override_attr->path_url = path_str; + attr->override_attr->ctrl_url = ctrl_str; + attr->override_attr->data_url = data_str; attr->raw_override_url = raw_url_str; attr->raw_override_path_url = raw_path_str; @@ -519,7 +550,8 @@ int lttng_load_session(struct lttng_load_session_attr *attr) session_name = attr->session_name[0] != '\0' ? attr->session_name : NULL; - ret = config_load_session(url, session_name, attr->overwrite, 0); + ret = config_load_session(url, session_name, attr->overwrite, 0, + attr->override_attr); end: return ret;