cds_list_for_each_entry_safe(wait_node, tmp_wait_node,
&wait_queue.head, head) {
health_code_update();
- if (wait_node->app->pid == ust_cmd->reg_msg.pid) {
+ /*
+ * Only using the pid number to match
+ * notify socket is not enough when
+ * dealing with multiple instances of
+ * lttng-ust for a given process. A
+ * similar problem will rise up when
+ * dealing with multiple similar pid
+ * across namespaces in the futur.
+ */
+ if (wait_node->app->pid ==
+ ust_cmd->reg_msg.pid) {
+ if ((wait_node->app->v_major !=
+ ust_cmd->reg_msg.major) &&
+ (wait_node->app->v_minor !=
+ ust_cmd->reg_msg.minor)) {
+ DBG("Skipping notify socket assignment (pid: %d) based on version mismatch. Notify socket registration version %d.%d, under iteration app version %d.%d.",
+ wait_node->app->pid,
+ ust_cmd->reg_msg.major,
+ ust_cmd->reg_msg.minor,
+ wait_node->app->v_major,
+ wait_node->app->v_minor);
+ continue;
+ }
wait_node->app->notify_sock = ust_cmd->sock;
cds_list_del(&wait_node->head);
wait_queue.count--;
app = wait_node->app;
free(wait_node);
wait_node = NULL;
- DBG3("UST app notify socket %d is set", ust_cmd->sock);
+ DBG3("UST app notify socket %d is set for app sock %d", ust_cmd->sock, app->sock);
break;
}
}
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);