static void delete_ust_app(struct ust_app *app)
{
int ret, sock;
- struct ust_app_session *ua_sess, *tmp_ua_sess;
struct lttng_ht_iter iter;
struct ust_app_event_notifier_rule *event_notifier_rule;
bool event_notifier_write_fd_is_open;
app->sock = -1;
/* Wipe sessions */
- cds_list_for_each_entry_safe (ua_sess, tmp_ua_sess, &app->teardown_head, teardown_node) {
- /* Free every object in the session and the session. */
+ {
const lttng::urcu::read_lock_guard read_lock;
- delete_ust_app_session(sock, ua_sess, app);
+
+ for (const auto ua_sess : app->sessions_to_teardown) {
+ /* Free every object in the session and the session. */
+ delete_ust_app_session(sock, ua_sess, app);
+ }
}
/* Remove the event notifier rules associated with this app. */
lttng_fd_put(LTTNG_FD_APPS, 1);
DBG2("UST app pid %d deleted", app->pid);
- free(app);
+ delete app;
}
/*
goto error;
}
- lta = zmalloc<ust_app>();
- if (lta == nullptr) {
- PERROR("malloc");
+ try {
+ lta = new ust_app;
+ } catch (const std::bad_alloc&) {
+ ERR_FMT("Failed to allocate ust application instance: name=`{}`, pid={}, uid={}",
+ msg->name,
+ msg->pid,
+ msg->uid);
goto error_free_pipe;
}
pthread_mutex_init(<a->sock_lock, nullptr);
lttng_ht_node_init_ulong(<a->sock_n, (unsigned long) lta->sock);
- CDS_INIT_LIST_HEAD(<a->teardown_head);
return lta;
error_free_pipe:
}
}
- cds_list_add(&ua_sess->teardown_node, &app.teardown_head);
+ app.sessions_to_teardown.emplace_back(ua_sess);
}
/*
*/
void ust_app_unregister_by_socket(int sock_fd)
{
- struct ust_app *app;
struct lttng_ht_node_ulong *node;
struct lttng_ht_iter ust_app_sock_iter;
int ret;
node = lttng_ht_iter_get_node<lttng_ht_node_ulong>(&ust_app_sock_iter);
assert(node);
- app = caa_container_of(node, struct ust_app, sock_n);
+ const auto app = lttng::utils::container_of(node, &ust_app::sock_n);
- DBG_FMT("Application unregistering after socket activity: pid={}, socket_fd={}",
- app->pid,
+ DBG_FMT("Application unregistering after socket activity: app={}, socket_fd={}",
+ *app,
sock_fd);
/* Remove application from socket hash table */
#include <common/uuid.hpp>
#include <stdint.h>
+#include <list>
#define UST_APP_EVENT_LIST_SIZE 32
struct lttng_credentials real_credentials = {};
/* Effective UID and GID. Same as the tracing session. */
struct lttng_credentials effective_credentials = {};
- struct cds_list_head teardown_node = {};
/*
* Once at least *one* session is created onto the application, the
* corresponding consumer is set so we can use it on unregistration.
* ht_del of ust_app_session associated to this app. This list is NOT used
* when a session is destroyed.
*/
- struct cds_list_head teardown_head;
+ std::list<ust_app_session *> sessions_to_teardown;
/*
* Hash table containing ust_app_channel indexed by channel objd.
*/