static pthread_mutex_t last_relay_viewer_session_id_lock =
PTHREAD_MUTEX_INITIALIZER;
+static
+const char *lttng_viewer_command_str(lttng_viewer_command cmd)
+{
+ switch (cmd) {
+ case LTTNG_VIEWER_CONNECT:
+ return "CONNECT";
+ case LTTNG_VIEWER_LIST_SESSIONS:
+ return "LIST_SESSIONS";
+ case LTTNG_VIEWER_ATTACH_SESSION:
+ return "ATTACH_SESSION";
+ case LTTNG_VIEWER_GET_NEXT_INDEX:
+ return "GET_NEXT_INDEX";
+ case LTTNG_VIEWER_GET_PACKET:
+ return "GET_PACKET";
+ case LTTNG_VIEWER_GET_METADATA:
+ return "GET_METADATA";
+ case LTTNG_VIEWER_GET_NEW_STREAMS:
+ return "GET_NEW_STREAMS";
+ case LTTNG_VIEWER_CREATE_SESSION:
+ return "CREATE_SESSION";
+ case LTTNG_VIEWER_DETACH_SESSION:
+ return "DETACH_SESSION";
+ default:
+ abort();
+ }
+}
+
/*
* Cleanup the daemon
*/
health_code_update();
- DBG("Viewer is establishing a connection to the relayd.");
-
ret = recv_request(conn->sock, &msg, sizeof(msg));
if (ret < 0) {
goto end;
uint32_t buf_count = SESSION_BUF_DEFAULT_COUNT;
uint32_t count = 0;
- DBG("List sessions received");
-
send_session_buf = (lttng_viewer_session *) zmalloc(SESSION_BUF_DEFAULT_COUNT * sizeof(*send_session_buf));
if (!send_session_buf) {
return -1;
LTTNG_ASSERT(conn);
- DBG("Get new streams received");
-
health_code_update();
/* Receive the request from the connected client. */
LTTNG_ASSERT(conn);
- DBG("Viewer get next index");
-
memset(&viewer_index, 0, sizeof(viewer_index));
health_code_update();
ssize_t read_len;
uint64_t stream_id;
- DBG2("Relay get data packet");
-
health_code_update();
ret = recv_request(conn->sock, &get_packet_info,
LTTNG_ASSERT(conn);
- DBG("Relay get metadata");
-
health_code_update();
ret = recv_request(conn->sock, &request, sizeof(request));
int ret;
struct lttng_viewer_create_session_response resp;
- DBG("Viewer create session received");
-
memset(&resp, 0, sizeof(resp));
resp.status = htobe32(LTTNG_VIEWER_CREATE_SESSION_OK);
conn->viewer_session = viewer_session_create();
struct relay_session *session = NULL;
uint64_t viewer_session_to_close;
- DBG("Viewer detach session received");
-
LTTNG_ASSERT(conn);
health_code_update();
struct relay_connection *conn)
{
int ret = 0;
- uint32_t msg_value;
-
- msg_value = be32toh(recv_hdr->cmd);
+ lttng_viewer_command cmd =
+ (lttng_viewer_command) be32toh(recv_hdr->cmd);
/*
- * Make sure we've done the version check before any command other then a
- * new client connection.
+ * Make sure we've done the version check before any command other then
+ * a new client connection.
*/
- if (msg_value != LTTNG_VIEWER_CONNECT && !conn->version_check_done) {
- ERR("Viewer conn value %" PRIu32 " before version check", msg_value);
+ if (cmd != LTTNG_VIEWER_CONNECT && !conn->version_check_done) {
+ ERR("Viewer on connection %d requested %s command before version check",
+ conn->sock->fd, lttng_viewer_command_str(cmd));
ret = -1;
goto end;
}
- switch (msg_value) {
+ DBG("Processing %s viewer command from connection %d",
+ lttng_viewer_command_str(cmd), conn->sock->fd);
+
+ switch (cmd) {
case LTTNG_VIEWER_CONNECT:
ret = viewer_connect(conn);
break;