/*
* Rotate all the channels of a session.
*
- * Return 0 on success or else a negative value.
+ * Return LTTNG_OK on success or else an LTTng error code.
*/
-int ust_app_rotate_session(struct ltt_session *session)
+enum lttng_error_code ust_app_rotate_session(struct ltt_session *session)
{
- int ret = 0;
+ int ret;
+ enum lttng_error_code cmd_ret = LTTNG_OK;
struct lttng_ht_iter iter;
struct ust_app *app;
struct ltt_ust_session *usess = session->ust_session;
socket = consumer_find_socket_by_bitness(reg->bits_per_long,
usess->consumer);
if (!socket) {
- ret = -EINVAL;
+ cmd_ret = LTTNG_ERR_INVALID;
goto error;
}
reg->uid, reg->bits_per_long);
if (ret < 0 || ret == sizeof(pathname)) {
PERROR("Failed to format rotation path");
+ cmd_ret = LTTNG_ERR_INVALID;
goto error;
}
/* is_metadata_channel */ false,
session->current_archive_id);
if (ret < 0) {
+ cmd_ret = LTTNG_ERR_ROTATION_FAIL_CONSUMER;
goto error;
}
}
/* is_metadata_channel */ true,
session->current_archive_id);
if (ret < 0) {
+ cmd_ret = LTTNG_ERR_ROTATION_FAIL_CONSUMER;
goto error;
}
}
ua_sess->path);
if (ret < 0 || ret == sizeof(pathname)) {
PERROR("Failed to format rotation path");
+ cmd_ret = LTTNG_ERR_INVALID;
goto error;
}
socket = consumer_find_socket_by_bitness(app->bits_per_long,
usess->consumer);
if (!socket) {
- ret = -EINVAL;
+ cmd_ret = LTTNG_ERR_INVALID;
goto error;
}
registry = get_session_registry(ua_sess);
if (!registry) {
- DBG("Application session is being torn down. Abort session rotation.");
- ret = -1;
- goto error;
+ DBG("Application session is being torn down. Skip application.");
+ continue;
}
/* is_metadata_channel */ false,
session->current_archive_id);
if (ret < 0) {
+ /* Per-PID buffer and application going away. */
+ if (ret == -LTTNG_ERR_CHAN_NOT_FOUND)
+ continue;
+ cmd_ret = LTTNG_ERR_ROTATION_FAIL_CONSUMER;
goto error;
}
}
/* is_metadata_channel */ true,
session->current_archive_id);
if (ret < 0) {
+ /* Per-PID buffer and application going away. */
+ if (ret == -LTTNG_ERR_CHAN_NOT_FOUND)
+ continue;
+ cmd_ret = LTTNG_ERR_ROTATION_FAIL_CONSUMER;
goto error;
}
}
break;
}
- ret = LTTNG_OK;
+ cmd_ret = LTTNG_OK;
error:
rcu_read_unlock();
- return ret;
+ return cmd_ret;
}