-error:
- health_code_update();
- /*
- * pthread_mutex_unlock(socket->lock);
- */
- return ret;
-}
-
-/*
- * Send a close metdata command to consumer using the given channel key.
- *
- * Return 0 on success else a negative value.
- */
-int ust_consumer_close_metadata(struct consumer_socket *socket,
- struct ust_app_channel *ua_chan)
-{
- int ret;
- struct lttcomm_consumer_msg msg;
-
- assert(ua_chan);
- assert(socket);
- assert(socket->fd >= 0);
-
- DBG2("UST consumer close metadata channel key %lu", ua_chan->key);
-
- msg.cmd_type = LTTNG_CONSUMER_CLOSE_METADATA;
- msg.u.close_metadata.key = ua_chan->key;
-
- pthread_mutex_lock(socket->lock);
- health_code_update();
-
- ret = consumer_send_msg(socket, &msg);
- if (ret < 0) {
- goto error;
+ reg_uid = buffer_reg_uid_find(request.session_id,
+ request.bits_per_long, request.uid);
+ if (reg_uid) {
+ ust_reg = reg_uid->registry->reg.ust;
+ } else {
+ struct buffer_reg_pid *reg_pid =
+ buffer_reg_pid_find(request.session_id_per_pid);
+ if (!reg_pid) {
+ DBG("PID registry not found for session id %" PRIu64,
+ request.session_id_per_pid);
+
+ msg.cmd_type = LTTNG_ERR_UND;
+ (void) consumer_send_msg(socket, &msg);
+ /*
+ * This is possible since the session might have been destroyed
+ * during a consumer metadata request. So here, return gracefully
+ * because the destroy session will push the remaining metadata to
+ * the consumer.
+ */
+ ret = 0;
+ goto end;
+ }
+ ust_reg = reg_pid->registry->reg.ust;