Add hooks to inform the notification subsystem of session rotation
state changes (ongoing or completed). This allows the notification
system to track the rotation state and inform clients that are
subscribed to those conditions.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#include <lttng/channel.h>
#include <lttng/channel-internal.h>
#include <lttng/rotate-internal.h>
#include <lttng/channel.h>
#include <lttng/channel-internal.h>
#include <lttng/rotate-internal.h>
+#include <lttng/location-internal.h>
#include <common/string-utils/string-utils.h>
#include "channel.h"
#include <common/string-utils/string-utils.h>
#include "channel.h"
session->rotation_state = LTTNG_ROTATION_STATE_ONGOING;
ret = notification_thread_command_session_rotation_ongoing(
notification_thread_handle,
session->rotation_state = LTTNG_ROTATION_STATE_ONGOING;
ret = notification_thread_command_session_rotation_ongoing(
notification_thread_handle,
- session->name, session->current_archive_id);
- if (ret) {
- ret = LTTNG_ERR_UNK;
- goto end;
+ session->name, session->uid, session->gid,
+ session->current_archive_id);
+ if (ret != LTTNG_OK) {
+ ERR("Failed to notify notification thread that a session rotation is ongoing for session %s",
+ session->name);
* session_list locks.
*/
if (!session->kernel_session && !ust_active) {
* session_list locks.
*/
if (!session->kernel_session && !ust_active) {
+ struct lttng_trace_archive_location *location;
+
+ session->rotate_pending = false;
+ session->rotation_state = LTTNG_ROTATION_STATE_COMPLETED;
ret = rename_complete_chunk(session, now);
if (ret < 0) {
ERR("Failed to rename completed rotation chunk");
goto end;
}
ret = rename_complete_chunk(session, now);
if (ret < 0) {
ERR("Failed to rename completed rotation chunk");
goto end;
}
- session->rotate_pending = false;
- session->rotation_state = LTTNG_ROTATION_STATE_COMPLETED;
+
+ /* Ownership of location is transferred. */
+ location = session_get_trace_archive_location(session);
+ ret = notification_thread_command_session_rotation_completed(
+ notification_thread_handle,
+ session->name,
+ session->uid,
+ session->gid,
+ session->current_archive_id,
+ location);
+ if (ret != LTTNG_OK) {
+ ERR("Failed to notify notification thread that rotation is complete for session %s",
+ session->name);
+ }
#include "cmd.h"
#include "session.h"
#include "sessiond-timer.h"
#include "cmd.h"
#include "session.h"
#include "sessiond-timer.h"
+#include "notification-thread-commands.h"
#include <urcu.h>
#include <urcu/list.h>
#include <urcu.h>
#include <urcu/list.h>
goto end_unlock_session;
}
} else {
goto end_unlock_session;
}
} else {
+ struct lttng_trace_archive_location *location;
+
session->rotation_state = LTTNG_ROTATION_STATE_COMPLETED;
session->rotation_state = LTTNG_ROTATION_STATE_COMPLETED;
+ /* Ownership of location is transferred. */
+ location = session_get_trace_archive_location(session);
+ ret = notification_thread_command_session_rotation_completed(
+ notification_thread_handle,
+ session->name,
+ session->uid,
+ session->gid,
+ session->current_archive_id,
+ location);
+ if (ret != LTTNG_OK) {
+ ERR("Failed to notify notification thread that rotation is complete for session %s",
+ session->name);
+ }
+
}
DBG("Rotation completed for session %s", session->name);
}
}
DBG("Rotation completed for session %s", session->name);
}
goto end;
}
if (ret == 0) {
goto end;
}
if (ret == 0) {
+ struct lttng_trace_archive_location *location;
+
DBG("[rotation-thread] Rotation completed on the relay for "
"session %" PRIu64, session->id);
/*
DBG("[rotation-thread] Rotation completed on the relay for "
"session %" PRIu64, session->id);
/*
*/
session->rotate_pending_relay = false;
session->rotation_state = LTTNG_ROTATION_STATE_COMPLETED;
*/
session->rotate_pending_relay = false;
session->rotation_state = LTTNG_ROTATION_STATE_COMPLETED;
+
+ session->rotation_state = LTTNG_ROTATION_STATE_COMPLETED;
+ /* Ownership of location is transferred. */
+ location = session_get_trace_archive_location(session);
+ ret = notification_thread_command_session_rotation_completed(
+ notification_thread_handle,
+ session->name,
+ session->uid,
+ session->gid,
+ session->current_archive_id,
+ location);
+ if (ret != LTTNG_OK) {
+ ERR("Failed to notify notification thread that rotation is complete for session %s",
+ session->name);
+ }
} else if (ret == 1) {
DBG("[rotation-thread] Rotation still pending on the relay for "
"session %" PRIu64, session->id);
} else if (ret == 1) {
DBG("[rotation-thread] Rotation still pending on the relay for "
"session %" PRIu64, session->id);