size_t mmap_len;
struct lttng_ust_shm_handle *handle;
int nr_streams;
- int shm_fd_is_copy;
int wait_fd_is_copy;
int cpucount;
};
if (stream->wait_fd >= 0 && !stream->wait_fd_is_copy) {
close(stream->wait_fd);
}
- if (stream->shm_fd >= 0 && stream->wait_fd != stream->shm_fd
- && !stream->shm_fd_is_copy) {
+ if (stream->shm_fd >= 0 && stream->wait_fd != stream->shm_fd) {
close(stream->shm_fd);
}
if (!--stream->chan->refcount)
if (channel->wait_fd >= 0 && !channel->wait_fd_is_copy) {
close(channel->wait_fd);
}
- if (channel->shm_fd >= 0 && channel->wait_fd != channel->shm_fd
- && !channel->shm_fd_is_copy) {
+ if (channel->shm_fd >= 0 && channel->wait_fd != channel->shm_fd) {
close(channel->shm_fd);
}
free(channel);
struct lttng_ht *ht;
/* Test size */
- size != 0 ? : (size = DEFAULT_HT_SIZE);
+ if (!size)
+ size = DEFAULT_HT_SIZE;
ht = zmalloc(sizeof(*ht));
if (ht == NULL) {
if (!chan->handle) {
return -ENOMEM;
}
- /*
- * The channel fds are passed to ustctl, we only keep a copy.
- */
- chan->shm_fd_is_copy = 1;
chan->wait_fd_is_copy = 1;
+ chan->shm_fd = -1;
return 0;
}
stream->buf = ustctl_open_stream_read(stream->chan->handle, stream->cpu);
if (!stream->buf)
return -EBUSY;
+ /* ustctl_open_stream_read has closed the shm fd. */
+ stream->wait_fd_is_copy = 1;
+ stream->shm_fd = -1;
+
stream->mmap_base = ustctl_get_mmap_base(stream->chan->handle, stream->buf);
if (!stream->mmap_base) {
return -EINVAL;
}
- /*
- * The stream fds are passed to ustctl, we only keep a copy.
- */
- stream->shm_fd_is_copy = 1;
- stream->wait_fd_is_copy = 1;
return 0;
}
unsigned int switch_timer_interval; /* usecs */
unsigned int read_timer_interval; /* usecs */
enum lttng_ust_output output; /* output mode */
- /* The following fields are used internally within UST. */
- int shm_fd;
- int wait_fd;
- uint64_t memory_map_size;
-};
-
-/*
- * This structure is only used internally within UST. It is not per-se
- * part of the communication between sessiond and UST.
- */
-struct lttng_ust_stream {
- int shm_fd;
- int wait_fd;
- uint64_t memory_map_size;
};
struct lttng_ust_event {
struct lttng_ust_obj;
+union ust_args {
+ struct {
+ int *shm_fd;
+ int *wait_fd;
+ uint64_t *memory_map_size;
+ } channel;
+ struct {
+ int *shm_fd;
+ int *wait_fd;
+ uint64_t *memory_map_size;
+ } stream;
+};
+
struct lttng_ust_objd_ops {
- long (*cmd)(int objd, unsigned int cmd, unsigned long arg);
+ long (*cmd)(int objd, unsigned int cmd, unsigned long arg,
+ union ust_args *args);
int (*release)(int objd);
};
usess = session->ust_session;
if (!session->enabled) {
- ret = LTTCOMM_UST_START_FAIL;
+ ret = LTTCOMM_UST_STOP_FAIL;
goto error;
}
ret = ust_app_stop_trace_all(usess);
if (ret < 0) {
- ret = LTTCOMM_UST_START_FAIL;
+ ret = LTTCOMM_UST_STOP_FAIL;
goto error;
}
}
}
ua_chan->handle = ua_chan->obj->handle;
- ua_chan->attr.shm_fd = ua_chan->obj->shm_fd;
- ua_chan->attr.wait_fd = ua_chan->obj->wait_fd;
- ua_chan->attr.memory_map_size = ua_chan->obj->memory_map_size;
DBG2("UST app channel %s created successfully for pid:%d and sock:%d",
ua_chan->name, app->key.pid, app->key.sock);