X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Flive.c;h=8c4f501aa3446afd5b5cb5d7e72e42bf82dd2d11;hb=3c42c3ed6dcfd89b1a41074c01e4b21ab8c599ae;hp=88bb7363db962a41e65c8ccff4a6a654cbc666a3;hpb=279cc4fe6584ba00b560e2fe59cce2eff4604820;p=lttng-tools.git diff --git a/src/bin/lttng-relayd/live.c b/src/bin/lttng-relayd/live.c index 88bb7363d..8c4f501aa 100644 --- a/src/bin/lttng-relayd/live.c +++ b/src/bin/lttng-relayd/live.c @@ -831,9 +831,18 @@ int viewer_list_sessions(struct relay_connection *conn) health_code_update(); + pthread_mutex_lock(&session->lock); if (session->connection_closed) { /* Skip closed session */ - continue; + goto next_session; + } + if (!session->current_trace_chunk) { + /* + * Skip un-attachable session. It is either + * being destroyed or has not had a trace + * chunk created against it yet. + */ + goto next_session; } if (count >= buf_count) { @@ -844,7 +853,7 @@ int viewer_list_sessions(struct relay_connection *conn) new_buf_count * sizeof(*send_session_buf)); if (!newbuf) { ret = -1; - break; + goto break_loop; } send_session_buf = newbuf; buf_count = new_buf_count; @@ -854,12 +863,12 @@ int viewer_list_sessions(struct relay_connection *conn) session->session_name, sizeof(send_session->session_name))) { ret = -1; - break; + goto break_loop; } if (lttng_strncpy(send_session->hostname, session->hostname, sizeof(send_session->hostname))) { ret = -1; - break; + goto break_loop; } send_session->id = htobe64(session->id); send_session->live_timer = htobe32(session->live_timer); @@ -870,6 +879,12 @@ int viewer_list_sessions(struct relay_connection *conn) } send_session->streams = htobe32(session->stream_count); count++; + next_session: + pthread_mutex_unlock(&session->lock); + continue; + break_loop: + pthread_mutex_unlock(&session->lock); + break; } rcu_read_unlock(); if (ret < 0) { @@ -2055,8 +2070,13 @@ restart: if (ret < 0) { goto error; } - lttng_poll_add(&events, conn->sock->fd, + ret = lttng_poll_add(&events, + conn->sock->fd, LPOLLIN | LPOLLRDHUP); + if (ret) { + ERR("Failed to add new live connection file descriptor to poll set"); + goto error; + } connection_ht_add(viewer_connections_ht, conn); DBG("Connection socket %d added to poll", conn->sock->fd); } else if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) {