summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
d31efcf)
Introduce a second hash table indexed by application socket which have
the exact same content as the hash table indexed by PID.
On unregister, we now use a direct lookup per socket instead of using
the key map between sock and PID. This prevents the PID-sock lookup race
when the unregister happens just after the replace and before the
close(fd).
We also use an add_replace call on application registration for the PID
hash table and kept the add_unique for the socket hash table.
(closes #7)
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
rcu_read_lock();
/* Delete ust app sessions info */
rcu_read_lock();
/* Delete ust app sessions info */
- sock = app->key.sock;
- app->key.sock = -1;
+ sock = app->sock;
+ app->sock = -1;
/* Wipe sessions */
cds_lfht_for_each_entry(app->sessions->ht, &iter.iter, ua_sess,
node.node) {
ret = lttng_ht_del(app->sessions, &iter);
assert(!ret);
/* Wipe sessions */
cds_lfht_for_each_entry(app->sessions->ht, &iter.iter, ua_sess,
node.node) {
ret = lttng_ht_del(app->sessions, &iter);
assert(!ret);
- delete_ust_app_session(app->key.sock, ua_sess);
+ delete_ust_app_session(app->sock, ua_sess);
}
lttng_ht_destroy(app->sessions);
/*
}
lttng_ht_destroy(app->sessions);
/*
- * Wait until we have removed the key from the sock hash table before
- * closing this socket, otherwise an application could re-use the socket ID
- * and race with the teardown, using the same hash table entry.
+ * Wait until we have deleted the application from the sock hash table
+ * before closing this socket, otherwise an application could re-use the
+ * socket ID and race with the teardown, using the same hash table entry.
+ *
+ * It's OK to leave the close in call_rcu. We want it to stay unique for
+ * all RCU readers that could run concurrently with unregister app,
+ * therefore we _need_ to only close that socket after a grace period. So
+ * it should stay in this RCU callback.
+ *
+ * This close() is a very important step of the synchronization model so
+ * every modification to this function must be carefully reviewed.
*/
ret = close(sock);
if (ret) {
PERROR("close");
}
*/
ret = close(sock);
if (ret) {
PERROR("close");
}
- DBG2("UST app pid %d deleted", app->key.pid);
+ DBG2("UST app pid %d deleted", app->pid);
free(app);
rcu_read_unlock();
free(app);
rcu_read_unlock();
struct lttng_ht_node_ulong *node =
caa_container_of(head, struct lttng_ht_node_ulong, head);
struct ust_app *app =
struct lttng_ht_node_ulong *node =
caa_container_of(head, struct lttng_ht_node_ulong, head);
struct ust_app *app =
- caa_container_of(node, struct ust_app, node);
+ caa_container_of(node, struct ust_app, pid_n);
- DBG3("Call RCU deleting app PID %d", app->key.pid);
+ DBG3("Call RCU deleting app PID %d", app->pid);
struct ust_app *find_app_by_sock(int sock)
{
struct lttng_ht_node_ulong *node;
struct ust_app *find_app_by_sock(int sock)
{
struct lttng_ht_node_ulong *node;
- struct ust_app_key *key;
struct lttng_ht_iter iter;
struct lttng_ht_iter iter;
- lttng_ht_lookup(ust_app_sock_key_map, (void *)((unsigned long) sock),
- &iter);
- node = lttng_ht_iter_get_node_ulong(&iter);
- if (node == NULL) {
- DBG2("UST app find by sock %d key not found", sock);
- goto error;
- }
- key = caa_container_of(node, struct ust_app_key, node);
-
- lttng_ht_lookup(ust_app_ht, (void *)((unsigned long) key->pid), &iter);
+ lttng_ht_lookup(ust_app_ht_by_sock, (void *)((unsigned long) sock), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (node == NULL) {
DBG2("UST app find by sock %d not found", sock);
goto error;
}
node = lttng_ht_iter_get_node_ulong(&iter);
if (node == NULL) {
DBG2("UST app find by sock %d not found", sock);
goto error;
}
- return caa_container_of(node, struct ust_app, node);
+
+ return caa_container_of(node, struct ust_app, sock_n);
- ret = ustctl_add_context(app->key.sock, &ua_ctx->ctx,
+ ret = ustctl_add_context(app->sock, &ua_ctx->ctx,
ua_chan->obj, &ua_ctx->obj);
if (ret < 0) {
goto error;
ua_chan->obj, &ua_ctx->obj);
if (ret < 0) {
goto error;
- ret = ustctl_add_context(app->key.sock, &ua_ctx->ctx,
+ ret = ustctl_add_context(app->sock, &ua_ctx->ctx,
ua_event->obj, &ua_ctx->obj);
if (ret < 0) {
goto error;
ua_event->obj, &ua_ctx->obj);
if (ret < 0) {
goto error;
- ret = ustctl_disable(app->key.sock, ua_event->obj);
+ ret = ustctl_disable(app->sock, ua_event->obj);
if (ret < 0) {
ERR("UST app event %s disable failed for app (pid: %d) "
"and session handle %d with ret %d",
if (ret < 0) {
ERR("UST app event %s disable failed for app (pid: %d) "
"and session handle %d with ret %d",
- ua_event->attr.name, app->key.pid, ua_sess->handle, ret);
+ ua_event->attr.name, app->pid, ua_sess->handle, ret);
goto error;
}
DBG2("UST app event %s disabled successfully for app (pid: %d)",
goto error;
}
DBG2("UST app event %s disabled successfully for app (pid: %d)",
- ua_event->attr.name, app->key.pid);
+ ua_event->attr.name, app->pid);
- ret = ustctl_disable(app->key.sock, ua_chan->obj);
+ ret = ustctl_disable(app->sock, ua_chan->obj);
if (ret < 0) {
ERR("UST app channel %s disable failed for app (pid: %d) "
"and session handle %d with ret %d",
if (ret < 0) {
ERR("UST app channel %s disable failed for app (pid: %d) "
"and session handle %d with ret %d",
- ua_chan->name, app->key.pid, ua_sess->handle, ret);
+ ua_chan->name, app->pid, ua_sess->handle, ret);
goto error;
}
DBG2("UST app channel %s disabled successfully for app (pid: %d)",
goto error;
}
DBG2("UST app channel %s disabled successfully for app (pid: %d)",
- ua_chan->name, app->key.pid);
+ ua_chan->name, app->pid);
- ret = ustctl_enable(app->key.sock, ua_chan->obj);
+ ret = ustctl_enable(app->sock, ua_chan->obj);
if (ret < 0) {
ERR("UST app channel %s enable failed for app (pid: %d) "
"and session handle %d with ret %d",
if (ret < 0) {
ERR("UST app channel %s enable failed for app (pid: %d) "
"and session handle %d with ret %d",
- ua_chan->name, app->key.pid, ua_sess->handle, ret);
+ ua_chan->name, app->pid, ua_sess->handle, ret);
goto error;
}
ua_chan->enabled = 1;
DBG2("UST app channel %s enabled successfully for app (pid: %d)",
goto error;
}
ua_chan->enabled = 1;
DBG2("UST app channel %s enabled successfully for app (pid: %d)",
- ua_chan->name, app->key.pid);
+ ua_chan->name, app->pid);
- ret = ustctl_enable(app->key.sock, ua_event->obj);
+ ret = ustctl_enable(app->sock, ua_event->obj);
if (ret < 0) {
ERR("UST app event %s enable failed for app (pid: %d) "
"and session handle %d with ret %d",
if (ret < 0) {
ERR("UST app event %s enable failed for app (pid: %d) "
"and session handle %d with ret %d",
- ua_event->attr.name, app->key.pid, ua_sess->handle, ret);
+ ua_event->attr.name, app->pid, ua_sess->handle, ret);
goto error;
}
DBG2("UST app event %s enabled successfully for app (pid: %d)",
goto error;
}
DBG2("UST app event %s enabled successfully for app (pid: %d)",
- ua_event->attr.name, app->key.pid);
+ ua_event->attr.name, app->pid);
uattr.output = ua_sess->metadata->attr.output;
/* UST tracer metadata creation */
uattr.output = ua_sess->metadata->attr.output;
/* UST tracer metadata creation */
- ret = ustctl_open_metadata(app->key.sock, ua_sess->handle, &uattr,
+ ret = ustctl_open_metadata(app->sock, ua_sess->handle, &uattr,
&ua_sess->metadata->obj);
if (ret < 0) {
ERR("UST app open metadata failed for app pid:%d with ret %d",
&ua_sess->metadata->obj);
if (ret < 0) {
ERR("UST app open metadata failed for app pid:%d with ret %d",
- ret = ustctl_create_stream(app->key.sock, ua_sess->metadata->obj,
+ ret = ustctl_create_stream(app->sock, ua_sess->metadata->obj,
&ua_sess->metadata->stream_obj);
if (ret < 0) {
ERR("UST create metadata stream failed");
&ua_sess->metadata->stream_obj);
if (ret < 0) {
ERR("UST create metadata stream failed");
int ret;
/* TODO: remove cast and use lttng-ust-abi.h */
int ret;
/* TODO: remove cast and use lttng-ust-abi.h */
- ret = ustctl_create_channel(app->key.sock, ua_sess->handle,
+ ret = ustctl_create_channel(app->sock, ua_sess->handle,
(struct lttng_ust_channel_attr *)&ua_chan->attr, &ua_chan->obj);
if (ret < 0) {
ERR("Creating channel %s for app (pid: %d, sock: %d) "
"and session handle %d with ret %d",
(struct lttng_ust_channel_attr *)&ua_chan->attr, &ua_chan->obj);
if (ret < 0) {
ERR("Creating channel %s for app (pid: %d, sock: %d) "
"and session handle %d with ret %d",
- ua_chan->name, app->key.pid, app->key.sock,
+ ua_chan->name, app->pid, app->sock,
ua_sess->handle, ret);
goto error;
}
ua_sess->handle, ret);
goto error;
}
ua_chan->handle = ua_chan->obj->handle;
DBG2("UST app channel %s created successfully for pid:%d and sock:%d",
ua_chan->handle = ua_chan->obj->handle;
DBG2("UST app channel %s created successfully for pid:%d and sock:%d",
- ua_chan->name, app->key.pid, app->key.sock);
+ ua_chan->name, app->pid, app->sock);
/* If channel is not enabled, disable it on the tracer */
if (!ua_chan->enabled) {
/* If channel is not enabled, disable it on the tracer */
if (!ua_chan->enabled) {
int ret = 0;
/* Create UST event on tracer */
int ret = 0;
/* Create UST event on tracer */
- ret = ustctl_create_event(app->key.sock, &ua_event->attr, ua_chan->obj,
+ ret = ustctl_create_event(app->sock, &ua_event->attr, ua_chan->obj,
&ua_event->obj);
if (ret < 0) {
if (ret == -EEXIST) {
&ua_event->obj);
if (ret < 0) {
if (ret == -EEXIST) {
goto error;
}
ERR("Error ustctl create event %s for app pid: %d with ret %d",
goto error;
}
ERR("Error ustctl create event %s for app pid: %d with ret %d",
- ua_event->attr.name, app->key.pid, ret);
+ ua_event->attr.name, app->pid, ret);
goto error;
}
ua_event->handle = ua_event->obj->handle;
DBG2("UST app event %s created successfully for pid:%d",
goto error;
}
ua_event->handle = ua_event->obj->handle;
DBG2("UST app event %s created successfully for pid:%d",
- ua_event->attr.name, app->key.pid);
+ ua_event->attr.name, app->pid);
/* If event not enabled, disable it on the tracer */
if (ua_event->enabled == 0) {
/* If event not enabled, disable it on the tracer */
if (ua_event->enabled == 0) {
ua_sess->gid = usess->gid;
ret = snprintf(ua_sess->path, PATH_MAX, "%s/%s-%d-%s", usess->pathname,
ua_sess->gid = usess->gid;
ret = snprintf(ua_sess->path, PATH_MAX, "%s/%s-%d-%s", usess->pathname,
- app->name, app->key.pid, datetime);
+ app->name, app->pid, datetime);
if (ret < 0) {
PERROR("asprintf UST shadow copy session");
/* TODO: We cannot return an error from here.. */
if (ret < 0) {
PERROR("asprintf UST shadow copy session");
/* TODO: We cannot return an error from here.. */
ua_sess = lookup_session_by_app(usess, app);
if (ua_sess == NULL) {
DBG2("UST app pid: %d session id %d not found, creating it",
ua_sess = lookup_session_by_app(usess, app);
if (ua_sess == NULL) {
DBG2("UST app pid: %d session id %d not found, creating it",
- app->key.pid, usess->id);
ua_sess = alloc_ust_app_session();
if (ua_sess == NULL) {
/* Only malloc can failed so something is really wrong */
ua_sess = alloc_ust_app_session();
if (ua_sess == NULL) {
/* Only malloc can failed so something is really wrong */
}
if (ua_sess->handle == -1) {
}
if (ua_sess->handle == -1) {
- ret = ustctl_create_session(app->key.sock);
+ ret = ustctl_create_session(app->sock);
- ERR("Creating session for app pid %d", app->key.pid);
+ ERR("Creating session for app pid %d", app->pid);
/* This means that the tracer is gone... */
ua_sess = (void*) -1UL;
goto error;
/* This means that the tracer is gone... */
ua_sess = (void*) -1UL;
goto error;
lttng_ht_add_unique_str(ua_sess->channels, &ua_chan->node);
DBG2("UST app create channel %s for PID %d completed", ua_chan->name,
lttng_ht_add_unique_str(ua_sess->channels, &ua_chan->node);
DBG2("UST app create channel %s for PID %d completed", ua_chan->name,
lttng_ht_add_unique_str(ua_chan->events, &ua_event->node);
DBG2("UST app create event %s for PID %d completed", ua_event->name,
lttng_ht_add_unique_str(ua_chan->events, &ua_event->node);
DBG2("UST app create event %s for PID %d completed", ua_event->name,
- DBG2("UST metadata opened for app pid %d", app->key.pid);
+ DBG2("UST metadata opened for app pid %d", app->pid);
}
/* Open UST metadata stream */
}
/* Open UST metadata stream */
}
DBG2("UST metadata stream object created for app pid %d",
}
DBG2("UST metadata stream object created for app pid %d",
} else {
ERR("Attempting to create stream without metadata opened");
goto error;
} else {
ERR("Attempting to create stream without metadata opened");
goto error;
DBG2("Found UST app by pid %d", pid);
DBG2("Found UST app by pid %d", pid);
- return caa_container_of(node, struct ust_app, node);
+ return caa_container_of(node, struct ust_app, pid_n);
error:
rcu_read_unlock();
error:
rcu_read_unlock();
lta->name[16] = '\0';
lta->sessions = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
lta->name[16] = '\0';
lta->sessions = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
- /* Set key map */
- lta->key.pid = msg->pid;
- lttng_ht_node_init_ulong(<a->node, (unsigned long)lta->key.pid);
- lta->key.sock = sock;
- lttng_ht_node_init_ulong(<a->key.node, (unsigned long)lta->key.sock);
+ lta->pid = msg->pid;
+ lttng_ht_node_init_ulong(<a->pid_n, (unsigned long)lta->pid);
+ lta->sock = sock;
+ lttng_ht_node_init_ulong(<a->sock_n, (unsigned long)lta->sock);
- lttng_ht_add_unique_ulong(ust_app_sock_key_map, <a->key.node);
- lttng_ht_add_unique_ulong(ust_app_ht, <a->node);
+
+ /*
+ * On a re-registration, we want to kick out the previous registration of
+ * that pid
+ */
+ lttng_ht_add_replace_ulong(ust_app_ht, <a->pid_n);
+
+ /*
+ * The socket _should_ be unique until _we_ call close. So, a add_unique
+ * for the ust_app_ht_by_sock is used which asserts fail if the entry was
+ * already in the table.
+ */
+ lttng_ht_add_unique_ulong(ust_app_ht_by_sock, <a->sock_n);
+
rcu_read_unlock();
DBG("App registered with pid:%d ppid:%d uid:%d gid:%d sock:%d name:%s"
rcu_read_unlock();
DBG("App registered with pid:%d ppid:%d uid:%d gid:%d sock:%d name:%s"
- " (version %d.%d)", lta->key.pid, lta->ppid, lta->uid, lta->gid,
- lta->key.sock, lta->name, lta->v_major, lta->v_minor);
+ " (version %d.%d)", lta->pid, lta->ppid, lta->uid, lta->gid,
+ lta->sock, lta->name, lta->v_major, lta->v_minor);
int ret;
rcu_read_lock();
int ret;
rcu_read_lock();
- lta = find_app_by_sock(sock);
- if (lta == NULL) {
- ERR("Unregister app sock %d not found!", sock);
- goto error;
- }
-
- DBG("PID %d unregistering with sock %d", lta->key.pid, sock);
-
- /* Remove application from socket hash table */
- lttng_ht_lookup(ust_app_sock_key_map, (void *)((unsigned long) sock), &iter);
- ret = lttng_ht_del(ust_app_sock_key_map, &iter);
- assert(!ret);
/* Get the node reference for a call_rcu */
/* Get the node reference for a call_rcu */
- lttng_ht_lookup(ust_app_ht, (void *)((unsigned long) lta->key.pid), &iter);
+ lttng_ht_lookup(ust_app_ht_by_sock, (void *)((unsigned long) sock), &iter);
node = lttng_ht_iter_get_node_ulong(&iter);
if (node == NULL) {
node = lttng_ht_iter_get_node_ulong(&iter);
if (node == NULL) {
- ERR("Unable to find app sock %d by pid %d", sock, lta->key.pid);
+ ERR("Unable to find app by sock %d", sock);
+ lta = caa_container_of(node, struct ust_app, sock_n);
+
+ DBG("PID %d unregistering with sock %d", lta->pid, sock);
+
/* Remove application from PID hash table */
/* Remove application from PID hash table */
+ ret = lttng_ht_del(ust_app_ht_by_sock, &iter);
+ assert(!ret);
+
+ /* Assign second node for deletion */
+ iter.iter.node = <a->pid_n.node;
+
ret = lttng_ht_del(ust_app_ht, &iter);
assert(!ret);
ret = lttng_ht_del(ust_app_ht, &iter);
assert(!ret);
- call_rcu(&node->head, delete_ust_app_rcu);
+
+ /* Free memory */
+ call_rcu(<a->pid_n.head, delete_ust_app_rcu);
+
error:
rcu_read_unlock();
return;
error:
rcu_read_unlock();
return;
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct lttng_ust_tracepoint_iter uiter;
if (!app->compatible) {
struct lttng_ust_tracepoint_iter uiter;
if (!app->compatible) {
- handle = ustctl_tracepoint_list(app->key.sock);
+ handle = ustctl_tracepoint_list(app->sock);
if (handle < 0) {
ERR("UST app list events getting handle failed for app pid %d",
if (handle < 0) {
ERR("UST app list events getting handle failed for app pid %d",
- while ((ret = ustctl_tracepoint_list_get(app->key.sock, handle,
+ while ((ret = ustctl_tracepoint_list_get(app->sock, handle,
&uiter)) != -ENOENT) {
if (count >= nbmem) {
DBG2("Reallocating event list from %zu to %zu entries", nbmem,
&uiter)) != -ENOENT) {
if (count >= nbmem) {
DBG2("Reallocating event list from %zu to %zu entries", nbmem,
memcpy(tmp[count].name, uiter.name, LTTNG_UST_SYM_NAME_LEN);
tmp[count].loglevel = uiter.loglevel;
tmp[count].type = LTTNG_UST_TRACEPOINT;
memcpy(tmp[count].name, uiter.name, LTTNG_UST_SYM_NAME_LEN);
tmp[count].loglevel = uiter.loglevel;
tmp[count].type = LTTNG_UST_TRACEPOINT;
- tmp[count].pid = app->key.pid;
+ tmp[count].pid = app->pid;
tmp[count].enabled = -1;
count++;
}
tmp[count].enabled = -1;
count++;
}
assert(!ret);
call_rcu(&node->head, delete_ust_app_rcu);
}
assert(!ret);
call_rcu(&node->head, delete_ust_app_rcu);
}
- /* Destroy is done only when the ht is empty */
- lttng_ht_destroy(ust_app_ht);
- cds_lfht_for_each_entry(ust_app_sock_key_map->ht, &iter.iter, node, node) {
- ret = lttng_ht_del(ust_app_sock_key_map, &iter);
+ /* Cleanup socket hash table */
+ cds_lfht_for_each_entry(ust_app_ht_by_sock->ht, &iter.iter, node, node) {
+ ret = lttng_ht_del(ust_app_ht_by_sock, &iter);
/* Destroy is done only when the ht is empty */
/* Destroy is done only when the ht is empty */
- lttng_ht_destroy(ust_app_sock_key_map);
+ lttng_ht_destroy(ust_app_ht);
+ lttng_ht_destroy(ust_app_ht_by_sock);
void ust_app_ht_alloc(void)
{
ust_app_ht = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
void ust_app_ht_alloc(void)
{
ust_app_ht = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
- ust_app_sock_key_map = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
+ ust_app_ht_by_sock = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
rcu_read_lock();
/* For every registered applications */
rcu_read_lock();
/* For every registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
struct lttng_ht_iter uiter;
if (!app->compatible) {
/*
struct lttng_ht_iter uiter;
if (!app->compatible) {
/*
rcu_read_lock();
/* For every registered applications */
rcu_read_lock();
/* For every registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
rcu_read_lock();
/* For all registered applications */
rcu_read_lock();
/* For all registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
ua_chan_node = lttng_ht_iter_get_node_str(&uiter);
if (ua_chan_node == NULL) {
DBG2("Channel %s not found in session id %d for app pid %d."
ua_chan_node = lttng_ht_iter_get_node_str(&uiter);
if (ua_chan_node == NULL) {
DBG2("Channel %s not found in session id %d for app pid %d."
- "Skipping", uchan->name, usess->id, app->key.pid);
+ "Skipping", uchan->name, usess->id, app->pid);
continue;
}
ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
continue;
}
ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
ua_event_node = lttng_ht_iter_get_node_str(&uiter);
if (ua_event_node == NULL) {
DBG2("Event %s not found in channel %s for app pid %d."
ua_event_node = lttng_ht_iter_get_node_str(&uiter);
if (ua_event_node == NULL) {
DBG2("Event %s not found in channel %s for app pid %d."
- "Skipping", uevent->attr.name, uchan->name, app->key.pid);
+ "Skipping", uevent->attr.name, uchan->name, app->pid);
continue;
}
ua_event = caa_container_of(ua_event_node, struct ust_app_event, node);
continue;
}
ua_event = caa_container_of(ua_event_node, struct ust_app_event, node);
rcu_read_lock();
/* For all registered applications */
rcu_read_lock();
/* For all registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
rcu_read_lock();
/* For every registered applications */
rcu_read_lock();
/* For every registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
rcu_read_lock();
/* For all registered applications */
rcu_read_lock();
/* For all registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
ua_event_node = lttng_ht_iter_get_node_str(&uiter);
if (ua_event_node == NULL) {
DBG3("UST app enable event %s not found for app PID %d."
ua_event_node = lttng_ht_iter_get_node_str(&uiter);
if (ua_event_node == NULL) {
DBG3("UST app enable event %s not found for app PID %d."
- "Skipping app", uevent->attr.name, app->key.pid);
+ "Skipping app", uevent->attr.name, app->pid);
continue;
}
ua_event = caa_container_of(ua_event_node, struct ust_app_event, node);
continue;
}
ua_event = caa_container_of(ua_event_node, struct ust_app_event, node);
rcu_read_lock();
/* For all registered applications */
rcu_read_lock();
/* For all registered applications */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
break;
}
DBG2("UST app event %s already exist on app PID %d",
break;
}
DBG2("UST app event %s already exist on app PID %d",
- uevent->attr.name, app->key.pid);
+ uevent->attr.name, app->pid);
struct ltt_ust_stream *ustream;
int consumerd_fd;
struct ltt_ust_stream *ustream;
int consumerd_fd;
- DBG("Starting tracing for ust app pid %d", app->key.pid);
+ DBG("Starting tracing for ust app pid %d", app->pid);
- ret = ustctl_create_stream(app->key.sock, ua_chan->obj,
+ ret = ustctl_create_stream(app->sock, ua_chan->obj,
&ustream->obj);
if (ret < 0) {
/* Got all streams */
&ustream->obj);
if (ret < 0) {
/* Got all streams */
skip_setup:
/* This start the UST tracing */
skip_setup:
/* This start the UST tracing */
- ret = ustctl_start_session(app->key.sock, ua_sess->handle);
+ ret = ustctl_start_session(app->sock, ua_sess->handle);
- ERR("Error starting tracing for app pid: %d", app->key.pid);
+ ERR("Error starting tracing for app pid: %d", app->pid);
goto error_rcu_unlock;
}
/* Quiescent wait after starting trace */
goto error_rcu_unlock;
}
/* Quiescent wait after starting trace */
- ustctl_wait_quiescent(app->key.sock);
+ ustctl_wait_quiescent(app->sock);
struct ust_app_session *ua_sess;
struct ust_app_channel *ua_chan;
struct ust_app_session *ua_sess;
struct ust_app_channel *ua_chan;
- DBG("Stopping tracing for ust app pid %d", app->key.pid);
+ DBG("Stopping tracing for ust app pid %d", app->pid);
assert(ua_sess->started == 1);
/* This inhibits UST tracing */
assert(ua_sess->started == 1);
/* This inhibits UST tracing */
- ret = ustctl_stop_session(app->key.sock, ua_sess->handle);
+ ret = ustctl_stop_session(app->sock, ua_sess->handle);
- ERR("Error stopping tracing for app pid: %d", app->key.pid);
+ ERR("Error stopping tracing for app pid: %d", app->pid);
goto error_rcu_unlock;
}
/* Quiescent wait after stopping trace */
goto error_rcu_unlock;
}
/* Quiescent wait after stopping trace */
- ustctl_wait_quiescent(app->key.sock);
+ ustctl_wait_quiescent(app->sock);
/* Flushing buffers */
cds_lfht_for_each_entry(ua_sess->channels->ht, &iter.iter, ua_chan,
node.node) {
/* Flushing buffers */
cds_lfht_for_each_entry(ua_sess->channels->ht, &iter.iter, ua_chan,
node.node) {
- ret = ustctl_sock_flush_buffer(app->key.sock, ua_chan->obj);
+ ret = ustctl_sock_flush_buffer(app->sock, ua_chan->obj);
if (ret < 0) {
ERR("UST app PID %d channel %s flush failed with ret %d",
if (ret < 0) {
ERR("UST app PID %d channel %s flush failed with ret %d",
- app->key.pid, ua_chan->name, ret);
+ app->pid, ua_chan->name, ret);
/* Continuing flushing all buffers */
continue;
}
}
/* Flush all buffers before stopping */
/* Continuing flushing all buffers */
continue;
}
}
/* Flush all buffers before stopping */
- ret = ustctl_sock_flush_buffer(app->key.sock, ua_sess->metadata->obj);
+ ret = ustctl_sock_flush_buffer(app->sock, ua_sess->metadata->obj);
- ERR("UST app PID %d metadata flush failed with ret %d", app->key.pid,
+ ERR("UST app PID %d metadata flush failed with ret %d", app->pid,
struct lttng_ht_node_ulong *node;
int ret;
struct lttng_ht_node_ulong *node;
int ret;
- DBG("Destroy tracing for ust app pid %d", app->key.pid);
+ DBG("Destroy tracing for ust app pid %d", app->pid);
obj.shm_fd = -1;
obj.wait_fd = -1;
obj.memory_map_size = 0;
obj.shm_fd = -1;
obj.wait_fd = -1;
obj.memory_map_size = 0;
- ustctl_release_object(app->key.sock, &obj);
+ ustctl_release_object(app->sock, &obj);
- delete_ust_app_session(app->key.sock, ua_sess);
+ delete_ust_app_session(app->sock, ua_sess);
/* Quiescent wait after stopping trace */
/* Quiescent wait after stopping trace */
- ustctl_wait_quiescent(app->key.sock);
+ ustctl_wait_quiescent(app->sock);
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ret = ust_app_start_trace(usess, app);
if (ret < 0) {
/* Continue to next apps even on error */
ret = ust_app_start_trace(usess, app);
if (ret < 0) {
/* Continue to next apps even on error */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ret = ust_app_stop_trace(usess, app);
if (ret < 0) {
/* Continue to next apps even on error */
ret = ust_app_stop_trace(usess, app);
if (ret < 0) {
/* Continue to next apps even on error */
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
ret = ust_app_destroy_trace(usess, app);
if (ret < 0) {
/* Continue to next apps even on error */
ret = ust_app_destroy_trace(usess, app);
if (ret < 0) {
/* Continue to next apps even on error */
- DBG2("UST trace started for app pid %d", app->key.pid);
+ DBG2("UST trace started for app pid %d", app->pid);
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
}
DBG2("UST app PID %d is compatible with major version %d "
}
DBG2("UST app PID %d is compatible with major version %d "
- "(supporting <= %d)", app->key.pid, app->version.major,
+ "(supporting <= %d)", app->pid, app->version.major,
UST_APP_MAJOR_VERSION);
app->compatible = 1;
rcu_read_unlock();
UST_APP_MAJOR_VERSION);
app->compatible = 1;
rcu_read_unlock();
error:
DBG2("UST app PID %d is not compatible with major version %d "
error:
DBG2("UST app PID %d is not compatible with major version %d "
- "(supporting <= %d)", app->key.pid, app->version.major,
+ "(supporting <= %d)", app->pid, app->version.major,
UST_APP_MAJOR_VERSION);
app->compatible = 0;
rcu_read_unlock();
UST_APP_MAJOR_VERSION);
app->compatible = 0;
rcu_read_unlock();
- cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, node.node) {
+ cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
if (!app->compatible) {
/*
* TODO: In time, we should notice the caller of this error by
- ret = ustctl_calibrate(app->key.sock, calibrate);
+ ret = ustctl_calibrate(app->sock, calibrate);
if (ret < 0) {
switch (ret) {
case -ENOSYS:
if (ret < 0) {
switch (ret) {
case -ENOSYS:
default:
/* TODO: Report error to user */
DBG2("Calibrate app PID %d returned with error %d",
default:
/* TODO: Report error to user */
DBG2("Calibrate app PID %d returned with error %d",
- * Global applications HT used by the session daemon.
+ * Global applications HT used by the session daemon. This table is indexed by
+ * PID using the pid_n node and pid value of an ust_app.
*/
struct lttng_ht *ust_app_ht;
*/
struct lttng_ht *ust_app_ht;
-struct lttng_ht *ust_app_sock_key_map;
-
-struct ust_app_key {
- pid_t pid;
- int sock;
- struct lttng_ht_node_ulong node;
-};
+/*
+ * Global applications HT used by the session daemon. This table is indexed by
+ * socket using the sock_n node and sock value of an ust_app.
+ */
+struct lttng_ht *ust_app_ht_by_sock;
struct ust_app_ctx {
int handle;
struct ust_app_ctx {
int handle;
* and a linked list is kept of all running traceable app.
*/
struct ust_app {
* and a linked list is kept of all running traceable app.
*/
struct ust_app {
pid_t ppid;
uid_t uid; /* User ID that owns the apps */
gid_t gid; /* Group ID that owns the apps */
pid_t ppid;
uid_t uid; /* User ID that owns the apps */
gid_t gid; /* Group ID that owns the apps */
uint32_t v_minor; /* Verion minor number */
char name[17]; /* Process name (short) */
struct lttng_ht *sessions;
uint32_t v_minor; /* Verion minor number */
char name[17]; /* Process name (short) */
struct lttng_ht *sessions;
- struct lttng_ht_node_ulong node;
- struct ust_app_key key;
+ struct lttng_ht_node_ulong pid_n;
+ struct lttng_ht_node_ulong sock_n;
};
#ifdef HAVE_LIBLTTNG_UST_CTL
};
#ifdef HAVE_LIBLTTNG_UST_CTL
struct lttng_ht_node_str *node);
extern void lttng_ht_add_unique_ulong(struct lttng_ht *ht,
struct lttng_ht_node_ulong *node);
struct lttng_ht_node_str *node);
extern void lttng_ht_add_unique_ulong(struct lttng_ht *ht,
struct lttng_ht_node_ulong *node);
-struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(struct lttng_ht *ht,
- struct lttng_ht_node_ulong *node);
+extern struct lttng_ht_node_ulong *lttng_ht_add_replace_ulong(
+ struct lttng_ht *ht, struct lttng_ht_node_ulong *node);
extern int lttng_ht_del(struct lttng_ht *ht, struct lttng_ht_iter *iter);
extern int lttng_ht_del(struct lttng_ht *ht, struct lttng_ht_iter *iter);