Skip to contentSkip to conversation

Fix: kernel track/untrack error handling

PATCH Jérémie Galarneau 1 participant 1 message Sep 5, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Jérémie Galarneau

author Applied
#1 lore raw

Merged, thanks!

While testing/reviewing this fix, I noticed that untracking a user space PID before enabling one (leaving the ust session pid_tracker uninitialized) would result in an "Invalid parameter" error being returned to the client (see bug #931).

The following commit addresses the problem:

commit b894343d659df2f6aa9ed50532fd4d8c0757e089

Author: Jérémie Galarneau <[email protected]>
Date:   Fri Sep 4 17:34:44 2015 -0400

Fix: Invalid parameter error reported when untracking PID

The LTTng client reports an "Invalid parameter" error if a PID is untracked from the userspace domain before any PID is tracked in that domain.

Fixes #931

Jérémie

Quoted 63 lines · Mathieu Desnoyers
Fixes #918
---
 src/bin/lttng-sessiond/kernel.c | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)
src/bin/lttng-sessiond/kernel.c +32 -3
index 570747f..381b83e 100644
@@ -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

Signature · 8 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev