switch (ua_sess->buffer_type) {
case LTTNG_BUFFER_PER_PID:
ret = snprintf(ua_sess->path, sizeof(ua_sess->path),
- DEFAULT_UST_TRACE_PID_PATH "/%s-%d-%s", app->name, app->pid,
- datetime);
+ DEFAULT_UST_TRACE_PID_PATH "/%s-%d-%s-%ld", app->name, app->pid,
+ datetime, ua_sess->id);
break;
case LTTNG_BUFFER_PER_UID:
ret = snprintf(ua_sess->path, sizeof(ua_sess->path),
switch (ua_sess->buffer_type) {
case LTTNG_BUFFER_PER_PID:
ret = snprintf(tmp_shm_path, sizeof(tmp_shm_path),
- "/" DEFAULT_UST_TRACE_PID_PATH "/%s-%d-%s",
- app->name, app->pid, datetime);
+ "/" DEFAULT_UST_TRACE_PID_PATH "/%s-%d-%s-%ld",
+ app->name, app->pid, datetime, ua_sess->id);
break;
case LTTNG_BUFFER_PER_UID:
ret = snprintf(tmp_shm_path, sizeof(tmp_shm_path),
}
/*
- * Return ust app pointer or NULL if not found. RCU read side lock MUST be
+ * Check if a ust_app with a given pid is present. RCU read side lock MUST be
* acquired before calling this function.
*/
-struct ust_app *ust_app_find_by_pid(pid_t pid)
+bool ust_app_with_pid_exists(pid_t pid)
{
- struct ust_app *app = NULL;
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter iter;
+ bool present = false;
lttng_ht_lookup(ust_app_ht, (void *)((unsigned long) pid), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (node == NULL) {
- DBG2("UST app no found with pid %d", pid);
- goto error;
+ DBG2("UST app not found with pid %d", pid);
+ goto end;
}
- DBG2("Found UST app by pid %d", pid);
-
- app = caa_container_of(node, struct ust_app, pid_n);
-
-error:
- return app;
+ present = true;
+end:
+ return present;
}
/*
rcu_read_lock();
/*
- * On a re-registration, we want to kick out the previous registration of
- * that pid
+ * Accept duplicate pid to accommodate the possibility of multiple
+ * lttng-ust per process. Both lttng-ust instance will register
+ * themselves and be unique in term of socket.
+ * All operations on pid should expects that multiple "app" be present
+ * with the same pid.
*/
- lttng_ht_add_replace_ulong(ust_app_ht, &app->pid_n);
+ lttng_ht_add_ulong(ust_app_ht, &app->pid_n);
/*
* The socket _should_ be unique until _we_ call close. So, a add_unique
iter.iter.node = <a->notify_sock_n.node;
(void) lttng_ht_del(ust_app_ht_by_notify_sock, &iter);
- /*
- * 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.
- */
iter.iter.node = <a->pid_n.node;
ret = lttng_ht_del(ust_app_ht, &iter);
- if (ret) {
- DBG3("Unregister app by PID %d failed. This can happen on pid reuse",
- lta->pid);
- }
+ assert(!ret);
/* Free memory */
call_rcu(<a->pid_n.head, delete_ust_app_rcu);