projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: add missing rcu_barrier before daemon teardown
[lttng-tools.git]
/
src
/
bin
/
lttng-relayd
/
main.c
diff --git
a/src/bin/lttng-relayd/main.c
b/src/bin/lttng-relayd/main.c
index 007f9513158d20aed0d89941f34e6f598e0606b9..919c5a96a7a2baa1680febd84ccb9e225fa3a386 100644
(file)
--- a/
src/bin/lttng-relayd/main.c
+++ b/
src/bin/lttng-relayd/main.c
@@
-161,10
+161,11
@@
static struct option long_options[] = {
{ "output", 1, 0, 'o', },
{ "verbose", 0, 0, 'v', },
{ "config", 1, 0, 'f' },
{ "output", 1, 0, 'o', },
{ "verbose", 0, 0, 'v', },
{ "config", 1, 0, 'f' },
+ { "version", 0, 0, 'V' },
{ NULL, 0, 0, 0, },
};
{ NULL, 0, 0, 0, },
};
-static const char *config_ignore_options[] = { "help", "config" };
+static const char *config_ignore_options[] = { "help", "config"
, "version"
};
/*
* Take an option from the getopt output and set it in the right variable to be
/*
* Take an option from the getopt output and set it in the right variable to be
@@
-255,6
+256,9
@@
static int set_option(int opt, const char *arg, const char *optname)
perror("exec");
}
exit(EXIT_FAILURE);
perror("exec");
}
exit(EXIT_FAILURE);
+ case 'V':
+ fprintf(stdout, "%s\n", VERSION);
+ exit(EXIT_SUCCESS);
case 'o':
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
case 'o':
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
@@
-582,9
+586,6
@@
int lttng_relay_stop_threads(void)
static void sighandler(int sig)
{
switch (sig) {
static void sighandler(int sig)
{
switch (sig) {
- case SIGPIPE:
- DBG("SIGPIPE caught");
- return;
case SIGINT:
DBG("SIGINT caught");
if (lttng_relay_stop_threads()) {
case SIGINT:
DBG("SIGINT caught");
if (lttng_relay_stop_threads()) {
@@
-620,9
+621,10
@@
static int set_signal_handler(void)
return ret;
}
return ret;
}
- sa.sa_handler = sighandler;
sa.sa_mask = sigset;
sa.sa_flags = 0;
sa.sa_mask = sigset;
sa.sa_flags = 0;
+
+ sa.sa_handler = sighandler;
if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
PERROR("sigaction");
return ret;
if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
PERROR("sigaction");
return ret;
@@
-633,12
+635,13
@@
static int set_signal_handler(void)
return ret;
}
return ret;
}
- if ((ret = sigaction(SIG
PIPE
, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIG
USR1
, &sa, NULL)) < 0) {
PERROR("sigaction");
return ret;
}
PERROR("sigaction");
return ret;
}
- if ((ret = sigaction(SIGUSR1, &sa, NULL)) < 0) {
+ sa.sa_handler = SIG_IGN;
+ if ((ret = sigaction(SIGPIPE, &sa, NULL)) < 0) {
PERROR("sigaction");
return ret;
}
PERROR("sigaction");
return ret;
}
@@
-1943,6
+1946,7
@@
static int relay_recv_index(struct lttcomm_relayd_hdr *recv_hdr,
struct lttcomm_relayd_generic_reply reply;
struct relay_stream *stream;
uint64_t net_seq_num;
struct lttcomm_relayd_generic_reply reply;
struct relay_stream *stream;
uint64_t net_seq_num;
+ size_t msg_len;
assert(conn);
assert(conn);
@@
-1954,9
+1958,12
@@
static int relay_recv_index(struct lttcomm_relayd_hdr *recv_hdr,
goto end_no_session;
}
goto end_no_session;
}
+ msg_len = lttcomm_relayd_index_len(
+ lttng_to_index_major(conn->major, conn->minor),
+ lttng_to_index_minor(conn->major, conn->minor));
ret = conn->sock->ops->recvmsg(conn->sock, &index_info,
ret = conn->sock->ops->recvmsg(conn->sock, &index_info,
-
sizeof(index_info)
, 0);
- if (ret <
sizeof(index_info)
) {
+
msg_len
, 0);
+ if (ret <
msg_len
) {
if (ret == 0) {
/* Orderly shutdown. Not necessary to print an error. */
DBG("Socket %d did an orderly shutdown", conn->sock->fd);
if (ret == 0) {
/* Orderly shutdown. Not necessary to print an error. */
DBG("Socket %d did an orderly shutdown", conn->sock->fd);
@@
-2180,41
+2187,36
@@
static int handle_index_data(struct relay_stream *stream, uint64_t net_seq_num,
goto end;
}
goto end;
}
- if (rotate_index || !stream->index_f
d
) {
-
int fd
;
+ if (rotate_index || !stream->index_f
ile
) {
+
uint32_t major, minor
;
- /* Put ref on previous index_f
d
. */
- if (stream->index_f
d
) {
-
stream_fd_put(stream->index_fd
);
- stream->index_f
d
= NULL;
+ /* Put ref on previous index_f
ile
. */
+ if (stream->index_f
ile
) {
+
lttng_index_file_put(stream->index_file
);
+ stream->index_f
ile
= NULL;
}
}
-
- fd = index_create_file(stream->path_name, stream->channel_name,
+ major = stream->trace->session->major;
+ minor = stream->trace->session->minor;
+ stream->index_file = lttng_index_file_create(stream->path_name,
+ stream->channel_name,
-1, -1, stream->tracefile_size,
-1, -1, stream->tracefile_size,
- tracefile_array_get_file_index_head(stream->tfa));
- if (fd < 0) {
- ret = -1;
- /* Put self-ref for this index due to error. */
- relay_index_put(index);
- goto end;
- }
- stream->index_fd = stream_fd_create(fd);
- if (!stream->index_fd) {
+ tracefile_array_get_file_index_head(stream->tfa),
+ lttng_to_index_major(major, minor),
+ lttng_to_index_minor(major, minor));
+ if (!stream->index_file) {
ret = -1;
ret = -1;
- if (close(fd)) {
- PERROR("Error closing FD %d", fd);
- }
/* Put self-ref for this index due to error. */
relay_index_put(index);
/* Put self-ref for this index due to error. */
relay_index_put(index);
- /* Will put the local ref. */
+ index = NULL;
goto end;
}
}
goto end;
}
}
- if (relay_index_set_f
d(index, stream->index_fd
, data_offset)) {
+ if (relay_index_set_f
ile(index, stream->index_file
, data_offset)) {
ret = -1;
/* Put self-ref for this index due to error. */
relay_index_put(index);
ret = -1;
/* Put self-ref for this index due to error. */
relay_index_put(index);
+ index = NULL;
goto end;
}
goto end;
}
@@
-2228,6
+2230,7
@@
static int handle_index_data(struct relay_stream *stream, uint64_t net_seq_num,
} else {
/* Put self-ref for this index due to error. */
relay_index_put(index);
} else {
/* Put self-ref for this index due to error. */
relay_index_put(index);
+ index = NULL;
ret = -1;
}
end:
ret = -1;
}
end:
@@
-2677,6
+2680,11
@@
error:
destroy_conn,
sock_n.node) {
health_code_update();
destroy_conn,
sock_n.node) {
health_code_update();
+
+ if (session_abort(destroy_conn->session)) {
+ assert(0);
+ }
+
/*
* No need to grab another ref, because we own
* destroy_conn.
/*
* No need to grab another ref, because we own
* destroy_conn.
@@
-2778,7
+2786,6
@@
int main(int argc, char **argv)
}
}
}
}
-
/* Initialize thread health monitoring */
health_relayd = health_app_create(NR_HEALTH_RELAYD_TYPES);
if (!health_relayd) {
/* Initialize thread health monitoring */
health_relayd = health_app_create(NR_HEALTH_RELAYD_TYPES);
if (!health_relayd) {
@@
-2834,7
+2841,7
@@
int main(int argc, char **argv)
}
/* Create thread to manage the client socket */
}
/* Create thread to manage the client socket */
- ret = pthread_create(&health_thread,
NULL
,
+ ret = pthread_create(&health_thread,
default_pthread_attr()
,
thread_manage_health, (void *) NULL);
if (ret) {
errno = ret;
thread_manage_health, (void *) NULL);
if (ret) {
errno = ret;
@@
-2844,7
+2851,7
@@
int main(int argc, char **argv)
}
/* Setup the dispatcher thread */
}
/* Setup the dispatcher thread */
- ret = pthread_create(&dispatcher_thread,
NULL
,
+ ret = pthread_create(&dispatcher_thread,
default_pthread_attr()
,
relay_thread_dispatcher, (void *) NULL);
if (ret) {
errno = ret;
relay_thread_dispatcher, (void *) NULL);
if (ret) {
errno = ret;
@@
-2854,7
+2861,7
@@
int main(int argc, char **argv)
}
/* Setup the worker thread */
}
/* Setup the worker thread */
- ret = pthread_create(&worker_thread,
NULL
,
+ ret = pthread_create(&worker_thread,
default_pthread_attr()
,
relay_thread_worker, NULL);
if (ret) {
errno = ret;
relay_thread_worker, NULL);
if (ret) {
errno = ret;
@@
-2864,7
+2871,7
@@
int main(int argc, char **argv)
}
/* Setup the listener thread */
}
/* Setup the listener thread */
- ret = pthread_create(&listener_thread,
NULL
,
+ ret = pthread_create(&listener_thread,
default_pthread_attr()
,
relay_thread_listener, (void *) NULL);
if (ret) {
errno = ret;
relay_thread_listener, (void *) NULL);
if (ret) {
errno = ret;
@@
-2930,6
+2937,12
@@
exit_init_data:
health_app_destroy(health_relayd);
exit_health_app_create:
exit_options:
health_app_destroy(health_relayd);
exit_health_app_create:
exit_options:
+ /*
+ * Wait for all pending call_rcu work to complete before tearing
+ * down data structures. call_rcu worker may be trying to
+ * perform lookups in those structures.
+ */
+ rcu_barrier();
relayd_cleanup();
/* Ensure all prior call_rcu are done. */
relayd_cleanup();
/* Ensure all prior call_rcu are done. */
This page took
0.02666 seconds
and
4
git commands to generate.