{
DBG("Cleaning up");
- /* Close thread quit pipes */
- utils_close_pipe(live_thread_quit_pipe);
free(live_uri);
}
futex_nto1_wake(&viewer_cmd_queue.futex);
}
-/*
- * Init thread quit pipe.
- *
- * Return -1 on error or 0 if all pipes are created.
- */
-static
-int init_thread_quit_pipe(void)
-{
- int ret;
-
- ret = utils_create_pipe_cloexec(live_thread_quit_pipe);
-
- return ret;
-}
-
/*
* Create a poll set with O_CLOEXEC and add the thread quit pipe to the set.
*/
}
session = caa_container_of(node, struct relay_session, session_n);
- if (cmd->session == session) {
+ if (cmd->session_id == session->id) {
/* Same viewer already attached, just send the stream list. */
send_streams = 1;
response.status = htobe32(VIEWER_ATTACH_OK);
session->viewer_attached++;
send_streams = 1;
response.status = htobe32(VIEWER_ATTACH_OK);
+ cmd->session_id = session->id;
cmd->session = session;
}
}
static
-void viewer_del_streams(struct relay_session *session)
+void viewer_del_streams(uint64_t session_id)
{
int ret;
struct relay_viewer_stream *stream;
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
- assert(session);
-
rcu_read_lock();
cds_lfht_for_each_entry(viewer_streams_ht->ht, &iter.iter, node, node) {
node = lttng_ht_iter_get_node_u64(&iter);
}
stream = caa_container_of(node, struct relay_viewer_stream, stream_n);
- if (stream->session_id != session->id) {
+ if (stream->session_id != session_id) {
continue;
}
ret = lttng_ht_del(relay_connections_ht, iter);
assert(!ret);
- if (relay_connection->session) {
- viewer_del_streams(relay_connection->session);
- }
+ viewer_del_streams(relay_connection->session_id);
call_rcu(&relay_connection->rcu_node, deferred_free_connection);
}
sock_n);
if (revents & (LPOLLERR)) {
- ERR("VIEWER POLL ERROR");
cleanup_poll_connection(&events, pollfd);
del_connection(relay_connections_ht, &iter,
relay_connection);
* main
*/
int live_start_threads(struct lttng_uri *uri,
- struct relay_local_data *relay_ctx)
+ struct relay_local_data *relay_ctx, int quit_pipe[2])
{
int ret = 0;
void *status;
assert(uri);
live_uri = uri;
- /* Create thread quit pipe */
- if ((ret = init_thread_quit_pipe()) < 0) {
- goto error;
- }
+ live_thread_quit_pipe[0] = quit_pipe[0];
+ live_thread_quit_pipe[1] = quit_pipe[1];
/* Check if daemon is UID = 0 */
is_root = !getuid();