This adds a new lttng error code being the "snapshot nodata".
Fixes #662
Signed-off-by: David Goulet <dgoulet@efficios.com>
LTTNG_ERR_UST_CONSUMER64_FAIL = 68, /* 64-bit UST consumer start failed */
LTTNG_ERR_UST_CONSUMER32_FAIL = 69, /* 32-bit UST consumer start failed */
LTTNG_ERR_UST_STREAM_FAIL = 70, /* UST create stream failed */
- /* 71 */
+ LTTNG_ERR_SNAPSHOT_NODATA = 71, /* No data in snapshot. */
/* 72 */
/* 73 */
LTTNG_ERR_UST_LIST_FAIL = 74, /* UST listing events failed */
ret = ust_app_snapshot_record(usess, output, wait, nb_streams);
if (ret < 0) {
- if (ret == -EINVAL) {
+ switch (-ret) {
+ case EINVAL:
ret = LTTNG_ERR_INVALID;
- goto error_snapshot;
+ break;
+ case ENODATA:
+ ret = LTTNG_ERR_SNAPSHOT_NODATA;
+ break;
+ default:
+ ret = LTTNG_ERR_SNAPSHOT_FAIL;
+ break;
}
-
- ret = LTTNG_ERR_SNAPSHOT_FAIL;
goto error_snapshot;
}
struct snapshot_output *output, int wait, unsigned int nb_streams)
{
int ret = 0;
+ unsigned int snapshot_done = 0;
struct lttng_ht_iter iter;
struct ust_app *app;
char pathname[PATH_MAX];
if (ret < 0) {
goto error;
}
+ snapshot_done = 1;
}
break;
}
if (ret < 0) {
goto error;
}
+ snapshot_done = 1;
}
break;
}
break;
}
+ if (!snapshot_done) {
+ /*
+ * If no snapshot was made and we are not in the error path, this means
+ * that there are no buffers thus no (prior) application to snapshot
+ * data from so we have simply NO data.
+ */
+ ret = -ENODATA;
+ }
+
error:
rcu_read_unlock();
return ret;
ret = handle_command(poptGetArgs(pc));
if (ret < 0) {
- if (ret == -LTTNG_ERR_EPERM) {
+ switch (-ret) {
+ case LTTNG_ERR_EPERM:
ERR("The session needs to be set in no output mode (--no-output)");
+ break;
+ case LTTNG_ERR_SNAPSHOT_NODATA:
+ WARN("%s", lttng_strerror(ret));
+ break;
+ default:
+ ERR("%s", lttng_strerror(ret));
+ break;
}
- ERR("%s", lttng_strerror(ret));
goto end;
}
[ ERROR_INDEX(LTTNG_ERR_SNAPSHOT_OUTPUT_EXIST) ] = "Snapshot output already exists",
[ ERROR_INDEX(LTTNG_ERR_START_SESSION_ONCE) ] = "Session needs to be started once",
[ ERROR_INDEX(LTTNG_ERR_SNAPSHOT_FAIL) ] = "Snapshot record failed",
+ [ ERROR_INDEX(LTTNG_ERR_SNAPSHOT_NODATA) ] = "No data available in snapshot",
/* Last element */
[ ERROR_INDEX(LTTNG_ERR_NR) ] = "Unknown error code"