2 * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_DESTRUCTION_HANDLE_H
9 #define LTTNG_DESTRUCTION_HANDLE_H
11 #include <lttng/lttng-error.h>
12 #include <lttng/lttng-export.h>
13 #include <lttng/rotation.h>
20 * Handle used to represent a specific instance of session destruction
23 * See lttng_destroy_session_ext() in lttng/session.h.
25 struct lttng_destruction_handle
;
28 * Negative values indicate errors. Values >= 0 indicate success.
30 enum lttng_destruction_handle_status
{
32 LTTNG_DESTRUCTION_HANDLE_STATUS_ERROR
= -2,
33 /* Invalid parameters provided */
34 LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID
= -1,
36 LTTNG_DESTRUCTION_HANDLE_STATUS_OK
= 0,
37 /* Destruction operation completed successfully. */
38 LTTNG_DESTRUCTION_HANDLE_STATUS_COMPLETED
= 1,
39 /* Operation timed out. */
40 LTTNG_DESTRUCTION_HANDLE_STATUS_TIMEOUT
= 2,
44 * Destroy an lttng_destruction_session handle.
45 * The handle should be discarded after this call.
47 LTTNG_EXPORT
extern void lttng_destruction_handle_destroy(struct lttng_destruction_handle
*handle
);
50 * Wait for the destruction of a session to complete.
52 * A negative timeout_ms value can be used to wait indefinitely.
54 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_COMPLETED if the session destruction
55 * operation was completed. LTTNG_DESTRUCTION_HANDLE_STATUS_TIMEOUT is returned
56 * to indicate that the wait timed out.
57 * On error, one of the negative lttng_destruction_handle_status is returned.
59 * Note: This function returning a success status does not mean that
60 * the destruction operation itself succeeded; it indicates that the _wait_
61 * operation completed successfully.
63 LTTNG_EXPORT
extern enum lttng_destruction_handle_status
64 lttng_destruction_handle_wait_for_completion(struct lttng_destruction_handle
*handle
,
68 * Get the result of a session destruction operation.
70 * This function must be used on a session destruction handle which was
71 * successfully waited on.
73 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_OK if the result of the session
74 * destruction operation could be obtained. Check the value of 'result' to
75 * determine if the destruction of the session completed successfully or not.
77 * On error, one of the negative lttng_destruction_handle_status is returned.
78 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID if the session destruction
79 * was not waited-on using the handle or if the arguments of the function are
80 * invalid (e.g. NULL).
82 LTTNG_EXPORT
extern enum lttng_destruction_handle_status
83 lttng_destruction_handle_get_result(const struct lttng_destruction_handle
*handle
,
84 enum lttng_error_code
*result
);
87 * Get the status of the session rotation performed as part of the session's
90 * A session will perform a final rotation if it was ever rotated over its
91 * lifetime. If this happens, this function returns the state of the rotation
94 * This function must be used on a session destruction handle which was
95 * successfully waited on.
97 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_OK if the state of the session
98 * rotation could be obtained. Check the value of 'rotation_state' to
99 * determine if the rotation of the session completed successfully or not.
101 * On error, one of the negative lttng_destruction_handle_status is returned.
102 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID if the session destruction
103 * was not waited-on using the handle or if the arguments of the function are
104 * invalid (e.g. NULL).
106 * Note that if no rotation was performed, rotation_state will be set to
107 * LTTNG_ROTATION_STATE_NO_ROTATION.
109 LTTNG_EXPORT
extern enum lttng_destruction_handle_status
110 lttng_destruction_handle_get_rotation_state(const struct lttng_destruction_handle
*handle
,
111 enum lttng_rotation_state
*rotation_state
);
114 * Get the location of the archive resulting from the rotation performed during
115 * the session's destruction.
117 * This function must be used on a session destruction handle which was
118 * successfully waited on and a session rotation must have been be completed
119 * successfully in order for this call to succeed.
121 * The location returned remains owned by the session destruction handle.
123 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_OK if the location of the archive
124 * resulting from the session rotation could be obtained.
126 * On error, one of the negative lttng_destruction_handle_status is returned.
127 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID if the session destruction
128 * was not waited-on using the handle, if no session rotation occurred as part
129 * of the session's destruction, or if the arguments of the function are
130 * invalid (e.g. NULL).
132 LTTNG_EXPORT
extern enum lttng_destruction_handle_status
133 lttng_destruction_handle_get_archive_location(const struct lttng_destruction_handle
*handle
,
134 const struct lttng_trace_archive_location
**location
);
140 #endif /* LTTNG_DESTRUCTION_HANDLE_H */