Fix: kernel track/untrack error handling
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 2 Sep 2015 14:45:07 +0000 (10:45 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 4 Sep 2015 22:43:43 +0000 (18:43 -0400)
Fixes #918

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/kernel.c

index 570747f183ac96f479fd0a7480919b27345221bd..381b83e6366c120128d9e6a639a081a24c54b684 100644 (file)
@@ -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,
This page took 0.027942 seconds and 4 git commands to generate.