[lttng-dev] [PATCH lttng-tools] Fix: kernel track/untrack error handling

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Wed Sep 2 10:45:07 EDT 2015


Fixes: #918

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 src/bin/lttng-sessiond/kernel.c | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c
index 570747f..381b83e 100644
--- a/src/bin/lttng-sessiond/kernel.c
+++ b/src/bin/lttng-sessiond/kernel.c
@@ -379,16 +379,46 @@ error:
 
 int kernel_track_pid(struct ltt_kernel_session *session, int pid)
 {
+	int ret;
+
 	DBG("Kernel track PID %d for session id %" PRIu64 ".",
 			pid, session->id);
-	return kernctl_track_pid(session->fd, pid);
+	ret = kernctl_track_pid(session->fd, pid);
+	if (!ret) {
+		return LTTNG_OK;
+	}
+	switch (errno) {
+	case EINVAL:
+		return LTTNG_ERR_INVALID;
+	case ENOMEM:
+		return LTTNG_ERR_NOMEM;
+	case EEXIST:
+		return LTTNG_ERR_PID_TRACKED;
+	default:
+		return LTTNG_ERR_UNK;
+	}
 }
 
 int kernel_untrack_pid(struct ltt_kernel_session *session, int pid)
 {
+	int ret;
+
 	DBG("Kernel untrack PID %d for session id %" PRIu64 ".",
 			pid, session->id);
-	return kernctl_untrack_pid(session->fd, pid);
+	ret = kernctl_untrack_pid(session->fd, pid);
+	if (!ret) {
+		return LTTNG_OK;
+	}
+	switch (errno) {
+	case EINVAL:
+		return LTTNG_ERR_INVALID;
+	case ENOMEM:
+		return LTTNG_ERR_NOMEM;
+	case ENOENT:
+		return LTTNG_ERR_PID_NOT_TRACKED;
+	default:
+		return LTTNG_ERR_UNK;
+	}
 }
 
 ssize_t kernel_list_tracker_pids(struct ltt_kernel_session *session,
-- 
2.1.4




More information about the lttng-dev mailing list