- * because at this point we are sure that the metadata producer is
- * either dead or blocked.
- */
- lttng_ustconsumer_close_metadata(metadata_ht);
- break;
- default:
- ERR("Unknown consumer_data type");
- assert(0);
- }
-}
-
-/*
- * Clean up a metadata stream and free its memory.
- */
-void consumer_del_metadata_stream(struct lttng_consumer_stream *stream,
- struct lttng_ht *ht)
-{
- int ret;
- struct lttng_ht_iter iter;
- struct lttng_consumer_channel *free_chan = NULL;
- struct consumer_relayd_sock_pair *relayd;
-
- assert(stream);
- /*
- * This call should NEVER receive regular stream. It must always be
- * metadata stream and this is crucial for data structure synchronization.
- */
- assert(stream->metadata_flag);
-
- DBG3("Consumer delete metadata stream %d", stream->wait_fd);
-
- if (ht == NULL) {
- /* Means the stream was allocated but not successfully added */
- goto free_stream_rcu;
- }
-
- pthread_mutex_lock(&consumer_data.lock);
- pthread_mutex_lock(&stream->chan->lock);
- pthread_mutex_lock(&stream->lock);
-
- switch (consumer_data.type) {
- case LTTNG_CONSUMER_KERNEL:
- if (stream->mmap_base != NULL) {
- ret = munmap(stream->mmap_base, stream->mmap_len);
- if (ret != 0) {
- PERROR("munmap metadata stream");
- }
- }
- if (stream->wait_fd >= 0) {
- ret = close(stream->wait_fd);
- if (ret < 0) {
- PERROR("close kernel metadata wait_fd");
- }
- }
- break;
- case LTTNG_CONSUMER32_UST:
- case LTTNG_CONSUMER64_UST:
- if (stream->monitor) {
- /* close the write-side in close_metadata */
- ret = close(stream->ust_metadata_poll_pipe[0]);
- if (ret < 0) {
- PERROR("Close UST metadata read-side poll pipe");
- }
- }
- lttng_ustconsumer_del_stream(stream);