- return ask_sessiond_varlen(&lsm, uris, sizeof(struct lttng_uri) * size,
- NULL);
+ ret = lttng_ctl_ask_sessiond_varlen(&lsm, uris,
+ sizeof(struct lttng_uri) * size, NULL);
+
+error:
+ free(uris);
+ return ret;
+}
+
+/*
+ * For a given session name, this call checks if the data is ready to be read
+ * or is still being extracted by the consumer(s) hence not ready to be used by
+ * any readers.
+ */
+int lttng_data_pending(const char *session_name)
+{
+ int ret;
+ struct lttcomm_session_msg lsm;
+
+ if (session_name == NULL) {
+ return -LTTNG_ERR_INVALID;
+ }
+
+ lsm.cmd_type = LTTNG_DATA_PENDING;
+
+ lttng_ctl_copy_string(lsm.session.name, session_name,
+ sizeof(lsm.session.name));
+
+ ret = lttng_ctl_ask_sessiond(&lsm, NULL);
+
+ /*
+ * The lttng_ctl_ask_sessiond function negate the return code if it's not
+ * LTTNG_OK so getting -1 means that the reply ret_code was 1 thus meaning
+ * that the data is available. Yes it is hackish but for now this is the
+ * only way.
+ */
+ if (ret == -1) {
+ ret = 1;
+ }
+
+ return ret;