lib: compile liblttng-ctl as C++
[lttng-tools.git] / include / lttng / destruction-handle.h
CommitLineData
3e3665b8 1/*
ab5be9fa 2 * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3e3665b8 3 *
ab5be9fa 4 * SPDX-License-Identifier: LGPL-2.1-only
3e3665b8 5 *
3e3665b8
JG
6 */
7
8#ifndef LTTNG_DESTRUCTION_HANDLE_H
9#define LTTNG_DESTRUCTION_HANDLE_H
10
11#include <lttng/rotation.h>
12#include <lttng/lttng-error.h>
4bd69c5f 13#include <lttng/lttng-export.h>
3e3665b8
JG
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
f16ab844
JG
19/*
20 * Handle used to represent a specific instance of session destruction
21 * operation.
22 *
23 * See lttng_destroy_session_ext() in lttng/session.h.
24 */
3e3665b8
JG
25struct lttng_destruction_handle;
26
f16ab844
JG
27/*
28 * Negative values indicate errors. Values >= 0 indicate success.
29 */
3e3665b8 30enum lttng_destruction_handle_status {
f16ab844 31 /* Generic error. */
3e3665b8 32 LTTNG_DESTRUCTION_HANDLE_STATUS_ERROR = -2,
f16ab844 33 /* Invalid parameters provided */
3e3665b8 34 LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID = -1,
f16ab844 35 /* Success. */
3e3665b8 36 LTTNG_DESTRUCTION_HANDLE_STATUS_OK = 0,
f16ab844 37 /* Destruction operation completed successfully. */
3e3665b8 38 LTTNG_DESTRUCTION_HANDLE_STATUS_COMPLETED = 1,
f16ab844 39 /* Operation timed out. */
3e3665b8
JG
40 LTTNG_DESTRUCTION_HANDLE_STATUS_TIMEOUT = 2,
41};
42
f16ab844
JG
43/*
44 * Destroy an lttng_destruction_session handle.
45 * The handle should be discarded after this call.
46 */
4bd69c5f 47LTTNG_EXPORT extern void lttng_destruction_handle_destroy(
3e3665b8
JG
48 struct lttng_destruction_handle *handle);
49
f16ab844
JG
50/*
51 * Wait for the destruction of a session to complete.
52 *
53 * A negative timeout_ms value can be used to wait indefinitely.
54 *
55 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_COMPLETED if the session destruction
56 * operation was completed. LTTNG_DESTRUCTION_HANDLE_STATUS_TIMEOUT is returned
57 * to indicate that the wait timed out.
58 * On error, one of the negative lttng_destruction_handle_status is returned.
59 *
60 * Note: This function returning a success status does not mean that
61 * the destruction operation itself succeeded; it indicates that the _wait_
62 * operation completed successfully.
63 */
4bd69c5f 64LTTNG_EXPORT extern enum lttng_destruction_handle_status
3e3665b8
JG
65lttng_destruction_handle_wait_for_completion(
66 struct lttng_destruction_handle *handle, int timeout_ms);
67
f16ab844
JG
68/*
69 * Get the result of a session destruction operation.
70 *
71 * This function must be used on a session destruction handle which was
72 * successfully waited on.
73 *
74 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_OK if the result of the session
75 * destruction operation could be obtained. Check the value of 'result' to
76 * determine if the destruction of the session completed successfully or not.
77 *
78 * On error, one of the negative lttng_destruction_handle_status is returned.
79 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID if the session destruction
80 * was not waited-on using the handle or if the arguments of the function are
81 * invalid (e.g. NULL).
82 */
4bd69c5f 83LTTNG_EXPORT extern enum lttng_destruction_handle_status
3e3665b8
JG
84lttng_destruction_handle_get_result(
85 const struct lttng_destruction_handle *handle,
86 enum lttng_error_code *result);
87
f16ab844
JG
88/*
89 * Get the status of the session rotation performed as part of the session's
90 * destruction.
91 *
92 * A session will perform a final rotation if it was ever rotated over its
93 * lifetime. If this happens, this function returns the state of the rotation
94 * that was performed.
95 *
96 * This function must be used on a session destruction handle which was
97 * successfully waited on.
98 *
99 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_OK if the state of the session
100 * rotation could be obtained. Check the value of 'rotation_state' to
101 * determine if the rotation of the session completed successfully or not.
102 *
103 * On error, one of the negative lttng_destruction_handle_status is returned.
104 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID if the session destruction
105 * was not waited-on using the handle or if the arguments of the function are
106 * invalid (e.g. NULL).
107 *
108 * Note that if no rotation was performed, rotation_state will be set to
109 * LTTNG_ROTATION_STATE_NO_ROTATION.
110 */
4bd69c5f 111LTTNG_EXPORT extern enum lttng_destruction_handle_status
3e3665b8
JG
112lttng_destruction_handle_get_rotation_state(
113 const struct lttng_destruction_handle *handle,
114 enum lttng_rotation_state *rotation_state);
115
f16ab844
JG
116/*
117 * Get the location of the archive resulting from the rotation performed during
118 * the session's destruction.
119 *
120 * This function must be used on a session destruction handle which was
121 * successfully waited on and a session rotation must have been be completed
122 * successfully in order for this call to succeed.
123 *
124 * The location returned remains owned by the session destruction handle.
125 *
126 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_OK if the location of the archive
127 * resulting from the session rotation could be obtained.
128 *
129 * On error, one of the negative lttng_destruction_handle_status is returned.
130 * Returns LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID if the session destruction
131 * was not waited-on using the handle, if no session rotation occurred as part
132 * of the session's destruction, or if the arguments of the function are
133 * invalid (e.g. NULL).
134 */
4bd69c5f 135LTTNG_EXPORT extern enum lttng_destruction_handle_status
3e3665b8
JG
136lttng_destruction_handle_get_archive_location(
137 const struct lttng_destruction_handle *handle,
138 const struct lttng_trace_archive_location **location);
139
4da7eebd
JG
140#ifdef __cplusplus
141}
142#endif
143
3e3665b8 144#endif /* LTTNG_DESTRUCTION_HANDLE_H */
This page took 0.03367 seconds and 4 git commands to generate.