- /* Remove from apps hash table */
- node = hashtable_lookup(ust_app_ht,
- (void *) ((unsigned long) lta->key.pid), sizeof(void *), &iter);
- if (node == NULL) {
- ERR("UST app pid %d not found in hash table", lta->key.pid);
- } else {
- ret = hashtable_del(ust_app_ht, &iter);
- if (ret) {
- ERR("UST app unable to delete app %d from hash table",
- lta->key.pid);
- } else {
- DBG2("UST app pid %d deleted", lta->key.pid);
- }
+ cds_lfht_for_each_entry(ua_chan->events, &iter, ua_event, node) {
+ hashtable_del(ua_chan->events, &iter);
+ delete_ust_app_event(sock, ua_event);
+ }
+
+ ret = hashtable_destroy(ua_chan->events);
+ if (ret < 0) {
+ ERR("UST app destroy session hashtable failed");
+ goto error;
+ }
+
+error:
+ return;
+}
+
+/*
+ * Delete ust app session safely. RCU read lock must be held before calling
+ * this function.
+ */
+static void delete_ust_app_session(int sock,
+ struct ust_app_session *ua_sess)
+{
+ int ret;
+ struct cds_lfht_iter iter;
+ struct ust_app_channel *ua_chan;
+
+ if (ua_sess->metadata) {
+ /*
+ * We do NOT release the stream object and metadata object since they
+ * are release when fds are sent to the consumer.
+ */
+ }
+
+ cds_lfht_for_each_entry(ua_sess->channels, &iter, ua_chan, node) {
+ hashtable_del(ua_sess->channels, &iter);
+ delete_ust_app_channel(sock, ua_chan);
+ }
+
+ ret = hashtable_destroy(ua_sess->channels);
+ if (ret < 0) {
+ ERR("UST app destroy session hashtable failed");
+ goto error;