The lock/unlock of the session list in the find session by name function
is removed thus the caller must held the lock before calling that search
function.
Also, the path and name are now static size on the stack and not
allocated strings at session creation.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
break;
default:
DBG("Getting session %s by name", cmd_ctx->lsm->session.name);
break;
default:
DBG("Getting session %s by name", cmd_ctx->lsm->session.name);
cmd_ctx->session = session_find_by_name(cmd_ctx->lsm->session.name);
cmd_ctx->session = session_find_by_name(cmd_ctx->lsm->session.name);
if (cmd_ctx->session == NULL) {
if (cmd_ctx->lsm->session.name != NULL) {
ret = LTTCOMM_SESS_NOT_FOUND;
if (cmd_ctx->session == NULL) {
if (cmd_ctx->lsm->session.name != NULL) {
ret = LTTCOMM_SESS_NOT_FOUND;
- * Return a ltt_session structure ptr that matches name.
- * If no session found, NULL is returned.
+ * Return a ltt_session structure ptr that matches name. If no session found,
+ * NULL is returned. This must be called with the session lock held using
+ * session_lock_list and session_unlock_list.
*/
struct ltt_session *session_find_by_name(char *name)
{
*/
struct ltt_session *session_find_by_name(char *name)
{
struct ltt_session *iter;
DBG2("Trying to find session by name %s", name);
struct ltt_session *iter;
DBG2("Trying to find session by name %s", name);
cds_list_for_each_entry(iter, <t_session_list.head, list) {
if (strncmp(iter->name, name, NAME_MAX) == 0) {
cds_list_for_each_entry(iter, <t_session_list.head, list) {
if (strncmp(iter->name, name, NAME_MAX) == 0) {
- if (!found) {
- iter = NULL;
- }
DBG("Destroying session %s", session->name);
del_session_list(session);
DBG("Destroying session %s", session->name);
del_session_list(session);
- free(session->name);
- free(session->path);
pthread_mutex_destroy(&session->lock);
free(session);
pthread_mutex_destroy(&session->lock);
free(session);
/* Define session name */
if (name != NULL) {
/* Define session name */
if (name != NULL) {
- if (asprintf(&new_session->name, "%s", name) < 0) {
+ if (snprintf(new_session->name, NAME_MAX, "%s", name) < 0) {
ret = LTTCOMM_FATAL;
goto error_asprintf;
}
ret = LTTCOMM_FATAL;
goto error_asprintf;
}
/* Define session system path */
if (path != NULL) {
/* Define session system path */
if (path != NULL) {
- if (asprintf(&new_session->path, "%s", path) < 0) {
+ if (snprintf(new_session->path, PATH_MAX, "%s", path) < 0) {
ret = LTTCOMM_FATAL;
goto error_asprintf;
}
ret = LTTCOMM_FATAL;
goto error_asprintf;
}
* session for both LTTng and UST.
*/
struct ltt_session {
* session for both LTTng and UST.
*/
struct ltt_session {
- char *name;
- char *path;
+ char name[NAME_MAX];
+ char path[PATH_MAX];
struct ltt_kernel_session *kernel_session;
struct ltt_ust_session_list ust_session_list;
/*
struct ltt_kernel_session *kernel_session;
struct ltt_ust_session_list ust_session_list;
/*