Fix: race with the viewer and readiness of streams
[lttng-tools.git] / src / common / relayd / relayd.c
index 448d19e6e30c2a16b89f3732147659b8159cf051..ccb23c065ca7aaeb8037fc30a42016fd7c9c9f3b 100644 (file)
@@ -293,6 +293,59 @@ error:
        return ret;
 }
 
+/*
+ * Inform the relay that all the streams for the current channel has been sent.
+ *
+ * On success return 0 else return ret_code negative value.
+ */
+int relayd_streams_sent(struct lttcomm_relayd_sock *rsock)
+{
+       int ret;
+       struct lttcomm_relayd_generic_reply reply;
+
+       /* Code flow error. Safety net. */
+       assert(rsock);
+
+       DBG("Relayd sending streams sent.");
+
+       /* This feature was introduced in 2.4, ignore it for earlier versions. */
+       if (rsock->minor < 4) {
+               ret = 0;
+               goto end;
+       }
+
+       /* Send command */
+       ret = send_command(rsock, RELAYD_STREAMS_SENT, NULL, 0, 0);
+       if (ret < 0) {
+               goto error;
+       }
+
+       /* Waiting for reply */
+       ret = recv_reply(rsock, (void *) &reply, sizeof(reply));
+       if (ret < 0) {
+               goto error;
+       }
+
+       /* Back to host bytes order. */
+       reply.ret_code = be32toh(reply.ret_code);
+
+       /* Return session id or negative ret code. */
+       if (reply.ret_code != LTTNG_OK) {
+               ret = -1;
+               ERR("Relayd streams sent replied error %d", reply.ret_code);
+               goto error;
+       } else {
+               /* Success */
+               ret = 0;
+       }
+
+       DBG("Relayd streams sent success");
+
+error:
+end:
+       return ret;
+}
+
 /*
  * Check version numbers on the relayd.
  * If major versions are compatible, we assign minor_to_use to the
This page took 0.023307 seconds and 4 git commands to generate.