sizeof(lsm.session.name));
ret = lttng_ctl_ask_sessiond(&lsm, (void **) &rotate_return);
- if (ret < 0) {
+ if (ret <= 0) {
*rotation_handle = NULL;
goto end;
}
switch (schedule->type) {
case LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD:
{
+ uint64_t threshold;
+
status = lttng_rotation_schedule_size_threshold_get_threshold(
- schedule, &lsm.u.rotation_set_schedule.value);
+ schedule, &threshold);
if (status != LTTNG_ROTATION_STATUS_OK) {
+ if (status == LTTNG_ROTATION_STATUS_UNAVAILABLE) {
+ status = LTTNG_ROTATION_STATUS_INVALID;
+ }
goto end;
}
-
+ lsm.u.rotation_set_schedule.value = threshold;
lsm.u.rotation_set_schedule.set = !!add;
break;
}
case LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC:
{
+ uint64_t period;
+
status = lttng_rotation_schedule_periodic_get_period(
- schedule, &lsm.u.rotation_set_schedule.value);
+ schedule, &period);
if (status != LTTNG_ROTATION_STATUS_OK) {
+ if (status == LTTNG_ROTATION_STATUS_UNAVAILABLE) {
+ status = LTTNG_ROTATION_STATUS_INVALID;
+ }
goto end;
}
-
+ lsm.u.rotation_set_schedule.value = period;
lsm.u.rotation_set_schedule.set = !!add;
break;
}
{
int ret;
struct lttcomm_session_msg lsm;
- struct lttng_session_list_schedules_return *schedules_comm;
+ struct lttng_session_list_schedules_return *schedules_comm = NULL;
struct lttng_rotation_schedules *schedules = NULL;
struct lttng_rotation_schedule *periodic = NULL, *size = NULL;
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
struct lttng_rotation_schedule_size_threshold *size_schedule;
- if (!schedule || !size_threshold_bytes) {
+ if (!schedule || !size_threshold_bytes ||
+ schedule->type != LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD) {
status = LTTNG_ROTATION_STATUS_INVALID;
goto end;
}
struct lttng_rotation_schedule_size_threshold *size_schedule;
if (!schedule || size_threshold_bytes == 0 ||
- size_threshold_bytes == -1ULL) {
+ size_threshold_bytes == -1ULL ||
+ schedule->type != LTTNG_ROTATION_SCHEDULE_TYPE_SIZE_THRESHOLD) {
status = LTTNG_ROTATION_STATUS_INVALID;
goto end;
}
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
struct lttng_rotation_schedule_periodic *periodic_schedule;
- if (!schedule || !period_us) {
+ if (!schedule || !period_us ||
+ schedule->type != LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC) {
status = LTTNG_ROTATION_STATUS_INVALID;
goto end;
}
enum lttng_rotation_status status = LTTNG_ROTATION_STATUS_OK;
struct lttng_rotation_schedule_periodic *periodic_schedule;
- if (!schedule || period_us == 0 || period_us == -1ULL) {
+ if (!schedule || period_us == 0 || period_us == -1ULL ||
+ schedule->type != LTTNG_ROTATION_SCHEDULE_TYPE_PERIODIC) {
status = LTTNG_ROTATION_STATUS_INVALID;
goto end;
}