#define BT_LOG_TAG "PLUGIN/SRC.CTF.LTTNG-LIVE/VIEWER"
#include "logging/comp-logging.h"
-#include <stdio.h>
+#include <fcntl.h>
+#include <stdbool.h>
#include <stdint.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <stdbool.h>
+#include <sys/types.h>
#include <unistd.h>
+
#include <glib.h>
-#include <inttypes.h>
-#include <sys/types.h>
-#include <fcntl.h>
#include "compat/socket.h"
#include "compat/endian.h"
}
}
-static
-void connection_release(bt_object *obj)
-{
- struct live_viewer_connection *conn =
- container_of(obj, struct live_viewer_connection, obj);
-
- live_viewer_connection_destroy(conn);
-}
-
static
int list_update_session(bt_value *results,
const struct lttng_viewer_session *session,
static
int receive_streams(struct lttng_live_session *session,
- uint32_t stream_count)
+ uint32_t stream_count,
+ bt_self_message_iterator *self_msg_iter)
{
ssize_t ret_len;
uint32_t i;
BT_COMP_LOGI(" stream %" PRIu64 " : %s/%s",
stream_id, stream.path_name, stream.channel_name);
live_stream = lttng_live_stream_iterator_create(session,
- ctf_trace_id, stream_id);
+ ctf_trace_id, stream_id, self_msg_iter);
if (!live_stream) {
BT_COMP_LOGE_APPEND_CAUSE(self_comp,
"Error creating stream");
BT_HIDDEN
enum lttng_live_attach_session_status lttng_live_attach_session(
- struct lttng_live_session *session)
+ struct lttng_live_session *session,
+ bt_self_message_iterator *self_msg_iter)
{
struct lttng_viewer_cmd cmd;
enum lttng_live_attach_session_status attach_status;
}
/* We receive the initial list of streams. */
- if (receive_streams(session, streams_count)) {
+ if (receive_streams(session, streams_count, self_msg_iter)) {
BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Error receiving streams");
goto error;
}
}
BT_HIDDEN
-enum bt_msg_iter_medium_status lttng_live_get_stream_bytes(
+enum ctf_msg_iter_medium_status lttng_live_get_stream_bytes(
struct lttng_live_msg_iter *lttng_live_msg_iter,
struct lttng_live_stream_iterator *stream, uint8_t *buf,
uint64_t offset, uint64_t req_len, uint64_t *recv_len)
{
- enum bt_msg_iter_medium_status retstatus = BT_MSG_ITER_MEDIUM_STATUS_OK;
+ enum ctf_msg_iter_medium_status retstatus = CTF_MSG_ITER_MEDIUM_STATUS_OK;
struct lttng_viewer_trace_packet rp;
struct lttng_viewer_cmd cmd;
struct lttng_viewer_get_packet rq;
case LTTNG_VIEWER_GET_PACKET_RETRY:
/* Unimplemented by relay daemon */
BT_COMP_LOGD("Received get_data_packet response: retry");
- retstatus = BT_MSG_ITER_MEDIUM_STATUS_AGAIN;
+ retstatus = CTF_MSG_ITER_MEDIUM_STATUS_AGAIN;
goto end;
case LTTNG_VIEWER_GET_PACKET_ERR:
if (flags & LTTNG_VIEWER_FLAG_NEW_METADATA) {
}
if (flags & (LTTNG_VIEWER_FLAG_NEW_METADATA
| LTTNG_VIEWER_FLAG_NEW_STREAM)) {
- retstatus = BT_MSG_ITER_MEDIUM_STATUS_AGAIN;
+ retstatus = CTF_MSG_ITER_MEDIUM_STATUS_AGAIN;
goto end;
}
BT_COMP_LOGE_APPEND_CAUSE(self_comp,
"Received get_data_packet response: error");
goto error;
case LTTNG_VIEWER_GET_PACKET_EOF:
- retstatus = BT_MSG_ITER_MEDIUM_STATUS_EOF;
+ retstatus = CTF_MSG_ITER_MEDIUM_STATUS_EOF;
goto end;
default:
BT_COMP_LOGE_APPEND_CAUSE(self_comp,
error:
if (lttng_live_graph_is_canceled(lttng_live_msg_iter)) {
- retstatus = BT_MSG_ITER_MEDIUM_STATUS_AGAIN;
+ retstatus = CTF_MSG_ITER_MEDIUM_STATUS_AGAIN;
} else {
- retstatus = BT_MSG_ITER_MEDIUM_STATUS_ERROR;
+ retstatus = CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
}
return retstatus;
}
*/
BT_HIDDEN
enum lttng_live_iterator_status lttng_live_get_new_streams(
- struct lttng_live_session *session)
+ struct lttng_live_session *session,
+ bt_self_message_iterator *self_msg_iter)
{
enum lttng_live_iterator_status status =
LTTNG_LIVE_ITERATOR_STATUS_OK;
goto error;
}
- if (receive_streams(session, streams_count)) {
+ if (receive_streams(session, streams_count, self_msg_iter)) {
BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Error receiving streams");
goto error;
}
viewer_connection->self_comp = self_comp;
viewer_connection->self_comp_class = self_comp_class;
- bt_object_init_shared(&viewer_connection->obj, connection_release);
viewer_connection->control_sock = BT_INVALID_SOCKET;
viewer_connection->port = -1;
viewer_connection->in_query = in_query;
struct live_viewer_connection *viewer_connection)
{
BT_COMP_LOGI("Closing connection to url \"%s\"", viewer_connection->url->str);
+
+ if (!viewer_connection) {
+ goto end;
+ }
+
lttng_live_disconnect_viewer(viewer_connection);
+
if (viewer_connection->url) {
g_string_free(viewer_connection->url, true);
}
+
if (viewer_connection->relay_hostname) {
g_string_free(viewer_connection->relay_hostname, true);
}
+
if (viewer_connection->target_hostname) {
g_string_free(viewer_connection->target_hostname, true);
}
+
if (viewer_connection->session_name) {
g_string_free(viewer_connection->session_name, true);
}
+
g_free(viewer_connection);
bt_socket_fini();
+
+end:
+ return;
}