Relay rotate pending command
[lttng-tools.git] / src / common / relayd / relayd.c
index 242abbedff15c5c2f079460cb8805dbc567268cd..995e4880197550575667d6e18ca613645b1916b5 100644 (file)
@@ -1086,6 +1086,56 @@ error:
        return ret;
 }
 
+int relayd_rotate_pending(struct lttcomm_relayd_sock *rsock, uint64_t chunk_id)
+{
+       int ret;
+       struct lttcomm_relayd_rotate_pending msg;
+       struct lttcomm_relayd_rotate_pending_reply reply;
+
+       /* Code flow error. Safety net. */
+       assert(rsock);
+
+       DBG("Querying relayd for rotate pending with chunk_id %" PRIu64,
+                       chunk_id);
+
+       memset(&msg, 0, sizeof(msg));
+       msg.chunk_id = htobe64(chunk_id);
+
+       /* Send command */
+       ret = send_command(rsock, RELAYD_ROTATE_PENDING, (void *) &msg,
+                       sizeof(msg), 0);
+       if (ret < 0) {
+               goto error;
+       }
+
+       /* Receive response */
+       ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
+       if (ret < 0) {
+               goto error;
+       }
+
+       reply.generic.ret_code = be32toh(reply.generic.ret_code);
+
+       /* Return session id or negative ret code. */
+       if (reply.generic.ret_code != LTTNG_OK) {
+               ret = -reply.generic.ret_code;
+               ERR("Relayd rotate pending replied with error %d", ret);
+               goto error;
+       } else {
+               /* No error, just rotate pending state */
+               if (reply.is_pending == 0 || reply.is_pending == 1) {
+                       ret = reply.is_pending;
+                       DBG("Relayd rotate pending command completed successfully with result \"%s\"",
+                                       ret ? "rotation pending" : "rotation NOT pending");
+               } else {
+                       ret = -LTTNG_ERR_UNK;
+               }
+       }
+
+error:
+       return ret;
+}
+
 int relayd_mkdir(struct lttcomm_relayd_sock *rsock, const char *path)
 {
        int ret;
This page took 0.0255 seconds and 5 git commands to generate.