Fix: Bad return error code handling
authorDavid Goulet <dgoulet@efficios.com>
Tue, 30 Oct 2012 19:11:18 +0000 (15:11 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 30 Oct 2012 19:21:46 +0000 (15:21 -0400)
Two things here. First, if the tracer dies before we have time to create
the session on it, the returned value (-1) was not handled creating a
segfault on the following loop.

Second, we no longer assert on the application PID hash table delete
return value since we use add_replace on app. registration creating a
possible key reuse for a different node.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/ust-app.c

index 96f8eb0b3ead316c0defa96905ff40cfcccb3136..e0562ed4e5448d2e184b288481fad0e80bb77b0b 100644 (file)
@@ -1506,8 +1506,16 @@ void ust_app_unregister(int sock)
        /* Assign second node for deletion */
        iter.iter.node = &lta->pid_n.node;
 
+       /*
+        * Ignore return value since the node might have been removed before by an
+        * add replace during app registration because the PID can be reassigned by
+        * the OS.
+        */
        ret = lttng_ht_del(ust_app_ht, &iter);
-       assert(!ret);
+       if (ret) {
+               DBG3("Unregister app by PID %d failed. This can happen on pid reuse",
+                               lta->pid);
+       }
 
        /* Free memory */
        call_rcu(&lta->pid_n.head, delete_ust_app_rcu);
@@ -2555,7 +2563,8 @@ void ust_app_global_update(struct ltt_ust_session *usess, int sock)
        }
 
        ua_sess = create_ust_app_session(usess, app);
-       if (ua_sess == NULL) {
+       if (ua_sess == NULL || ua_sess == (void *) -1UL) {
+               /* Tracer is gone for this session and has been freed */
                goto error;
        }
 
This page took 0.027403 seconds and 4 git commands to generate.