X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=ltt-sessiond%2Fmain.c;h=241a1cffd32533ee56f11299e7748b043b4a7da1;hb=7442b2ba0c15bf9c950b96a19e948243c2b57683;hp=70ce53c8b1cd50c87e1712bc42a2c2e0ba0f9bd4;hpb=1657e9bb835a28e66396deac871270fe373d5ff4;p=lttng-tools.git diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 70ce53c8b..241a1cffd 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -35,7 +35,7 @@ #include /* URCU list library (-lurcu) */ #include /* UST control lib (-lust) */ -#include +#include #include "liblttsessiondcomm.h" #include "ltt-sessiond.h" @@ -242,6 +242,7 @@ static int connect_app(pid_t pid) lta = find_app_by_pid(pid); if (lta == NULL) { /* App not found */ + DBG("Application pid %d not found", pid); return -1; } @@ -374,6 +375,42 @@ error: return ret; } +/* + * ust_stop_trace + * + * Stop a trace. This trace, identified by the pid, must be + * in the current session ust_traces list. + */ +static int ust_stop_trace(pid_t pid) +{ + int sock, ret; + struct ltt_ust_trace *trace; + + DBG("Stopping trace for pid %d", pid); + + trace = find_session_ust_trace_by_pid(current_session, pid); + if (trace == NULL) { + ret = LTTCOMM_NO_TRACE; + goto error; + } + + /* Connect to app using ustctl API */ + sock = connect_app(pid); + if (sock < 0) { + ret = LTTCOMM_NO_TRACEABLE; + goto error; + } + + ret = ustctl_stop_trace(sock, trace->name); + if (ret < 0) { + ret = LTTCOMM_STOP_FAIL; + goto error; + } + +error: + return ret; +} + /* * copy_common_data * @@ -564,6 +601,13 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) /* No auxiliary data so only send the llm struct. */ goto end; } + case UST_STOP_TRACE: + { + ret = ust_stop_trace(lsm->pid); + + /* No auxiliary data so only send the llm struct. */ + goto end; + } case LTTNG_LIST_SESSIONS: { unsigned int session_count = get_session_count(); @@ -602,6 +646,7 @@ static int process_client_msg(int sock, struct lttcomm_session_msg *lsm) return ret; end: + DBG("Return code to client %d", ret); /* Notify client of error */ llm.ret_code = ret; llm.size_payload = 0;