- ua_sess = lookup_session_by_app(usess, app);
- if (ua_sess == NULL) {
- DBG2("UST app (pid: %d, sock: %d) session not found, creating one",
- app->key.pid, app->key.sock);
- ua_sess = alloc_app_session();
- if (ua_sess == NULL) {
- /* Only malloc can failed so something is really wrong */
- goto next;
- }
- shallow_copy_session(ua_sess, usess);
- }
-
- if (ua_sess->handle == -1) {
- ret = ustctl_create_session(app->key.sock);
- if (ret < 0) {
- DBG("Error creating session for app pid %d, sock %d",
- app->key.pid, app->key.sock);
- /* TODO: free() ua_sess */
- goto next;
- }
-
- DBG2("UST app ustctl create session handle %d", ret);
- ua_sess->handle = ret;
- /* Add ust app session to app's HT */
- hashtable_node_init(&ua_sess->node,
- (void *)((unsigned long) ua_sess->uid), sizeof(void *));
- hashtable_add_unique(app->sessions, &ua_sess->node);
- }
-
- /* Lookup channel in the ust app session */
- ua_chan_node = hashtable_lookup(ua_sess->channels,
- (void *) uchan->name, strlen(uchan->name), &iter);
- if (ua_chan_node == NULL) {
- ERR("Channel suppose to be present with the above shallow "
- "session copy. Continuing...");
- goto next;
- }
-
- ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);