Fix: DBG statement in relayd
[lttng-tools.git] / src / common / relayd / relayd.c
index 56ca98223a383bd6d9a36b288decea7c677505ac..45cb097f616c1bf65b31d5d66ba45966e0877d8b 100644 (file)
@@ -33,7 +33,7 @@
  * Send command. Fill up the header and append the data.
  */
 static int send_command(struct lttcomm_sock *sock,
-               enum lttcomm_sessiond_command cmd, void *data, size_t size,
+               enum lttcomm_relayd_command cmd, void *data, size_t size,
                int flags)
 {
        int ret;
@@ -457,7 +457,7 @@ int relayd_data_pending(struct lttcomm_sock *sock, uint64_t stream_id,
        ret = reply.ret_code;
 
        DBG("Relayd data is %s pending for stream id %" PRIu64,
-                       ret == 1 ? "NOT" : "", stream_id);
+                       ret == 1 ? "" : "NOT", stream_id);
 
 error:
        return ret;
@@ -466,9 +466,11 @@ error:
 /*
  * Check on the relayd side for a quiescent state on the control socket.
  */
-int relayd_quiescent_control(struct lttcomm_sock *sock)
+int relayd_quiescent_control(struct lttcomm_sock *sock,
+               uint64_t metadata_stream_id)
 {
        int ret;
+       struct lttcomm_relayd_quiescent_control msg;
        struct lttcomm_relayd_generic_reply reply;
 
        /* Code flow error. Safety net. */
@@ -476,8 +478,10 @@ int relayd_quiescent_control(struct lttcomm_sock *sock)
 
        DBG("Relayd checking quiescent control state");
 
+       msg.stream_id = htobe64(metadata_stream_id);
+
        /* Send command */
-       ret = send_command(sock, RELAYD_QUIESCENT_CONTROL, NULL, 0, 0);
+       ret = send_command(sock, RELAYD_QUIESCENT_CONTROL, &msg, sizeof(msg), 0);
        if (ret < 0) {
                goto error;
        }
@@ -503,3 +507,94 @@ int relayd_quiescent_control(struct lttcomm_sock *sock)
 error:
        return ret;
 }
+
+/*
+ * Begin a data pending command for a specific session id.
+ */
+int relayd_begin_data_pending(struct lttcomm_sock *sock, uint64_t id)
+{
+       int ret;
+       struct lttcomm_relayd_begin_data_pending msg;
+       struct lttcomm_relayd_generic_reply reply;
+
+       /* Code flow error. Safety net. */
+       assert(sock);
+
+       DBG("Relayd begin data pending");
+
+       msg.session_id = htobe64(id);
+
+       /* Send command */
+       ret = send_command(sock, RELAYD_BEGIN_DATA_PENDING, &msg, sizeof(msg), 0);
+       if (ret < 0) {
+               goto error;
+       }
+
+       /* Recevie response */
+       ret = recv_reply(sock, (void *) &reply, sizeof(reply));
+       if (ret < 0) {
+               goto error;
+       }
+
+       reply.ret_code = be32toh(reply.ret_code);
+
+       /* Return session id or negative ret code. */
+       if (reply.ret_code != LTTNG_OK) {
+               ret = -reply.ret_code;
+               ERR("Relayd begin data pending replied error %d", ret);
+               goto error;
+       }
+
+       return 0;
+
+error:
+       return ret;
+}
+
+/*
+ * End a data pending command for a specific session id.
+ *
+ * Return 0 on success and set is_data_inflight to 0 if no data is being
+ * streamed or 1 if it is the case.
+ */
+int relayd_end_data_pending(struct lttcomm_sock *sock, uint64_t id,
+               unsigned int *is_data_inflight)
+{
+       int ret;
+       struct lttcomm_relayd_end_data_pending msg;
+       struct lttcomm_relayd_generic_reply reply;
+
+       /* Code flow error. Safety net. */
+       assert(sock);
+
+       DBG("Relayd end data pending");
+
+       msg.session_id = htobe64(id);
+
+       /* Send command */
+       ret = send_command(sock, RELAYD_END_DATA_PENDING, &msg, sizeof(msg), 0);
+       if (ret < 0) {
+               goto error;
+       }
+
+       /* Recevie response */
+       ret = recv_reply(sock, (void *) &reply, sizeof(reply));
+       if (ret < 0) {
+               goto error;
+       }
+
+       reply.ret_code = be32toh(reply.ret_code);
+       if (reply.ret_code < 0) {
+               ret = reply.ret_code;
+               goto error;
+       }
+
+       *is_data_inflight = reply.ret_code;
+
+       DBG("Relayd end data pending is data inflight: %d", reply.ret_code);
+
+       return 0;
+
+error:
+       return ret;
+}
This page took 0.024395 seconds and 4 git commands to generate.