Fix: Metadata stream leak when received in consumer
[lttng-tools.git] / src / common / relayd / relayd.c
index 7e99dbb674c1c304836fe72727a8fa07e2ee0a61..cf3649397425840b9c0c0e0ae07d22073255f0fa 100644 (file)
@@ -70,7 +70,7 @@ static int send_command(struct lttcomm_sock *sock,
                goto error;
        }
 
-       DBG3("Relayd sending command %d", cmd);
+       DBG3("Relayd sending command %d of size %" PRIu64, cmd, buf_size);
 
 error:
        free(buf);
@@ -86,7 +86,7 @@ static int recv_reply(struct lttcomm_sock *sock, void *data, size_t size)
 {
        int ret;
 
-       DBG3("Relayd waiting for reply...");
+       DBG3("Relayd waiting for reply of size %ld", size);
 
        ret = sock->ops->recvmsg(sock, data, size, 0);
        if (ret < 0) {
@@ -97,58 +97,6 @@ error:
        return ret;
 }
 
-#if 0
-/*
- * Create session on the relayd.
- *
- * On error, return ret_code negative value else return 0.
- */
-int relayd_create_session(struct lttcomm_sock *sock, const char *hostname,
-               const char *session_name)
-{
-       int ret;
-       struct lttcomm_relayd_create_session msg;
-       struct lttcomm_relayd_generic_reply reply;
-
-       /* Code flow error. Safety net. */
-       assert(sock);
-       assert(hostname);
-       assert(session_name);
-
-       DBG("Relayd creating session for hostname %s and session name %s",
-                       hostname, session_name);
-
-       strncpy(msg.hostname, hostname, sizeof(msg.hostname));
-       strncpy(msg.session_name, session_name, sizeof(msg.session_name));
-
-       /* Send command */
-       ret = send_command(sock, RELAYD_CREATE_SESSION, (void *) &msg,
-                       sizeof(msg), 0);
-       if (ret < 0) {
-               goto error;
-       }
-
-       /* Recevie response */
-       ret = recv_reply(sock, (void *) &reply, sizeof(reply));
-       if (ret < 0) {
-               goto error;
-       }
-
-       /* Return session id or negative ret code. */
-       if (reply.ret_code != LTTCOMM_OK) {
-               ret = -reply.ret_code;
-       } else {
-               /* Success */
-               ret = 0;
-       }
-
-       DBG2("Relayd created session for %s", session_name);
-
-error:
-       return ret;
-}
-#endif
-
 /*
  * Add stream on the relayd and assign stream handle to the stream_id argument.
  *
@@ -177,7 +125,7 @@ int relayd_add_stream(struct lttcomm_sock *sock, const char *channel_name,
                goto error;
        }
 
-       /* Recevie response */
+       /* Waiting for reply */
        ret = recv_reply(sock, (void *) &reply, sizeof(reply));
        if (ret < 0) {
                goto error;
@@ -188,7 +136,7 @@ int relayd_add_stream(struct lttcomm_sock *sock, const char *channel_name,
        reply.ret_code = be32toh(reply.ret_code);
 
        /* Return session id or negative ret code. */
-       if (reply.ret_code != LTTCOMM_OK) {
+       if (reply.ret_code != LTTNG_OK) {
                ret = -reply.ret_code;
                ERR("Relayd add stream replied error %d", ret);
        } else {
@@ -255,47 +203,6 @@ error:
        return ret;
 }
 
-#if 0
-/*
- * Start data command on the relayd.
- *
- * On success return 0 else return ret_code negative value.
- */
-int relayd_start_data(struct lttcomm_sock *sock)
-{
-       int ret;
-       struct lttcomm_relayd_generic_reply reply;
-
-       /* Code flow error. Safety net. */
-       assert(sock);
-
-       DBG("Relayd start data command");
-
-       /* Send command */
-       ret = send_command(sock, RELAYD_START_DATA, NULL, 0, 0);
-       if (ret < 0) {
-               goto error;
-       }
-
-       /* Recevie response */
-       ret = recv_reply(sock, (void *) &reply, sizeof(reply));
-       if (ret < 0) {
-               goto error;
-       }
-
-       /* Return session id or negative ret code. */
-       if (reply.ret_code != LTTCOMM_OK) {
-               ret = -reply.ret_code;
-       } else {
-               /* Success */
-               ret = 0;
-       }
-
-error:
-       return ret;
-}
-#endif
-
 /*
  * Add stream on the relayd and assign stream handle to the stream_id argument.
  *
@@ -321,7 +228,7 @@ int relayd_send_metadata(struct lttcomm_sock *sock, size_t len)
        /*
         * After that call, the metadata data MUST be sent to the relayd so the
         * receive size on the other end matches the len of the metadata packet
-        * header.
+        * header. This is why we don't wait for a reply here.
         */
 
 error:
@@ -366,7 +273,7 @@ int relayd_send_data_hdr(struct lttcomm_sock *sock,
        assert(sock);
        assert(hdr);
 
-       DBG3("Relayd sending data header...");
+       DBG3("Relayd sending data header of size %ld", size);
 
        /* Again, safety net */
        if (size == 0) {
@@ -421,7 +328,7 @@ int relayd_send_close_stream(struct lttcomm_sock *sock, uint64_t stream_id,
        reply.ret_code = be32toh(reply.ret_code);
 
        /* Return session id or negative ret code. */
-       if (reply.ret_code != LTTCOMM_OK) {
+       if (reply.ret_code != LTTNG_OK) {
                ret = -reply.ret_code;
                ERR("Relayd close stream replied error %d", ret);
        } else {
This page took 0.029787 seconds and 5 git commands to generate.