projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Run clang-format on the whole tree
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
thread-utils.cpp
diff --git
a/src/bin/lttng-sessiond/thread-utils.cpp
b/src/bin/lttng-sessiond/thread-utils.cpp
index 2d8f8b78913415efd120efdcd1fa2935a181fc30..5e8579a5e5fd65567e463256fb348ead05f671ff 100644
(file)
--- a/
src/bin/lttng-sessiond/thread-utils.cpp
+++ b/
src/bin/lttng-sessiond/thread-utils.cpp
@@
-7,36
+7,39
@@
*
*/
*
*/
-#include "lttng-sessiond.h"
-#include "utils.h"
-#include <common/utils.h>
+#include "lttng-sessiond.hpp"
+#include "utils.hpp"
+
+#include <common/utils.hpp>
+
#include <pthread.h>
/*
#include <pthread.h>
/*
- * Quit pipe for all threads. This permits a single cancellation point
- * for all threads when receiving an event on the pipe.
+ * Quit pipe for the main thread. This is used by signal handlers to start the
+ * shutdown sequence of the main thread which will tear down the other threads
+ * in the appropriate order.
*/
*/
-static int
thread
_quit_pipe[2] = { -1, -1 };
+static int
main
_quit_pipe[2] = { -1, -1 };
/*
/*
- * Init
thread
quit pipe.
+ * Init
main
quit pipe.
*
* Return -1 on error or 0 if all pipes are created.
*/
*
* Return -1 on error or 0 if all pipes are created.
*/
-
static int __init_thread_quit_pipe(int *a_pipe
)
+
int sessiond_init_main_quit_pipe(void
)
{
int ret, i;
{
int ret, i;
- ret = pipe(
a
_pipe);
+ ret = pipe(
main_quit
_pipe);
if (ret < 0) {
if (ret < 0) {
- PERROR("
thread
quit pipe");
+ PERROR("
main
quit pipe");
goto error;
}
for (i = 0; i < 2; i++) {
goto error;
}
for (i = 0; i < 2; i++) {
- ret = fcntl(
a
_pipe[i], F_SETFD, FD_CLOEXEC);
+ ret = fcntl(
main_quit
_pipe[i], F_SETFD, FD_CLOEXEC);
if (ret < 0) {
if (ret < 0) {
- PERROR("fcntl");
+ PERROR("fcntl
main_quit_pipe
");
goto error;
}
}
goto error;
}
}
@@
-45,25
+48,15
@@
error:
return ret;
}
return ret;
}
-int sessiond_init_thread_quit_pipe(void)
-{
- return __init_thread_quit_pipe(thread_quit_pipe);
-}
-
-int sessiond_check_thread_quit_pipe(int fd, uint32_t events)
-{
- return (fd == thread_quit_pipe[0] && (events & LPOLLIN));
-}
-
/*
/*
- * Wait for a notification on the quit pipe (with a timeout).
+ * Wait for a notification on the
main
quit pipe (with a timeout).
*
* A timeout value of -1U means no timeout.
*
* Returns 1 if the caller should quit, 0 if the timeout was reached, and
* -1 if an error was encountered.
*/
*
* A timeout value of -1U means no timeout.
*
* Returns 1 if the caller should quit, 0 if the timeout was reached, and
* -1 if an error was encountered.
*/
-int sessiond_wait_for_quit_pipe(int timeout_ms)
+int sessiond_wait_for_
main_
quit_pipe(int timeout_ms)
{
int ret;
struct lttng_poll_event events;
{
int ret;
struct lttng_poll_event events;
@@
-74,7
+67,7
@@
int sessiond_wait_for_quit_pipe(int timeout_ms)
ret = -1;
goto end;
}
ret = -1;
goto end;
}
- ret = lttng_poll_add(&events,
thread_quit_pipe[0], LPOLLIN | LPOLLERR
);
+ ret = lttng_poll_add(&events,
main_quit_pipe[0], LPOLLIN
);
if (ret < 0) {
PERROR("Failed to add file descriptor to poll/epoll set");
ret = -1;
if (ret < 0) {
PERROR("Failed to add file descriptor to poll/epoll set");
ret = -1;
@@
-86,7
+79,7
@@
int sessiond_wait_for_quit_pipe(int timeout_ms)
ret = 1;
} else if (ret < 0 && errno != EINTR) {
/* Unknown error. */
ret = 1;
} else if (ret < 0 && errno != EINTR) {
/* Unknown error. */
- PERROR("Failed to epoll()/poll()
thread
quit pipe");
+ PERROR("Failed to epoll()/poll()
main
quit pipe");
ret = -1;
} else {
/* Timeout reached. */
ret = -1;
} else {
/* Timeout reached. */
@@
-98,19
+91,20
@@
end:
return ret;
}
return ret;
}
-int sessiond_notify_quit_pipe(void)
+int sessiond_notify_
main_
quit_pipe(void)
{
{
- return notify_thread_pipe(
thread
_quit_pipe[1]);
+ return notify_thread_pipe(
main
_quit_pipe[1]);
}
}
-void sessiond_close_quit_pipe(void)
+void sessiond_close_
main_
quit_pipe(void)
{
{
- utils_close_pipe(
thread
_quit_pipe);
+ utils_close_pipe(
main
_quit_pipe);
}
}
-static
-int __sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size,
- int *a_pipe)
+/*
+ * Create a poll set with O_CLOEXEC and add the main quit pipe to the set.
+ */
+int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size)
{
int ret;
{
int ret;
@@
-121,8
+115,8
@@
int __sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size,
goto error;
}
goto error;
}
- /* Add quit pipe */
- ret = lttng_poll_add(events,
a_pipe[0], LPOLLIN | LPOLLERR
);
+ /* Add
main
quit pipe */
+ ret = lttng_poll_add(events,
main_quit_pipe[0], LPOLLIN
);
if (ret < 0) {
goto error;
}
if (ret < 0) {
goto error;
}
@@
-132,11
+126,3
@@
int __sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size,
error:
return ret;
}
error:
return ret;
}
-
-/*
- * Create a poll set with O_CLOEXEC and add the thread quit pipe to the set.
- */
-int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size)
-{
- return __sessiond_set_thread_pollset(events, size, thread_quit_pipe);
-}
This page took
0.027171 seconds
and
4
git commands to generate.