projects
/
deliverable
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
relayd: Don't bypass the fd tracker when closing file descriptors
[deliverable/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 f61f1f13e69ce72eedfc53d3a1941951ae50041c..ed424d9dd0c9036768aeff6d29e4d2a146210308 100644
(file)
--- a/
src/bin/lttng-relayd/main.c
+++ b/
src/bin/lttng-relayd/main.c
@@
-63,6
+63,7
@@
#include <common/dynamic-buffer.h>
#include <common/buffer-view.h>
#include <common/string-utils/format.h>
#include <common/dynamic-buffer.h>
#include <common/buffer-view.h>
#include <common/string-utils/format.h>
+#include <common/fd-tracker/fd-tracker.h>
#include "backward-compatibility-group-by.h"
#include "cmd.h"
#include "backward-compatibility-group-by.h"
#include "cmd.h"
@@
-179,6
+180,9
@@
struct health_app *health_relayd;
struct sessiond_trace_chunk_registry *sessiond_trace_chunk_registry;
struct sessiond_trace_chunk_registry *sessiond_trace_chunk_registry;
+/* Global fd tracker. */
+struct fd_tracker *the_fd_tracker;
+
static struct option long_options[] = {
{ "control-port", 1, 0, 'C', },
{ "data-port", 1, 0, 'D', },
static struct option long_options[] = {
{ "control-port", 1, 0, 'C', },
{ "data-port", 1, 0, 'D', },
@@
-631,13
+635,9
@@
exit:
static void print_global_objects(void)
{
static void print_global_objects(void)
{
- rcu_register_thread();
-
print_viewer_streams();
print_relay_streams();
print_sessions();
print_viewer_streams();
print_relay_streams();
print_sessions();
-
- rcu_unregister_thread();
}
/*
}
/*
@@
-659,9
+659,21
@@
static void relayd_cleanup(void)
free(opt_output_path);
free(opt_working_directory);
free(opt_output_path);
free(opt_working_directory);
+ if (health_relayd) {
+ health_app_destroy(health_relayd);
+ }
/* Close thread quit pipes */
/* Close thread quit pipes */
+ utils_close_pipe(health_quit_pipe);
utils_close_pipe(thread_quit_pipe);
utils_close_pipe(thread_quit_pipe);
+ if (sessiond_trace_chunk_registry) {
+ sessiond_trace_chunk_registry_destroy(
+ sessiond_trace_chunk_registry);
+ }
+ if (the_fd_tracker) {
+ fd_tracker_destroy(the_fd_tracker);
+ }
+
uri_free(control_uri);
uri_free(data_uri);
/* Live URI is freed in the live thread. */
uri_free(control_uri);
uri_free(data_uri);
/* Live URI is freed in the live thread. */
@@
-669,6
+681,7
@@
static void relayd_cleanup(void)
if (tracing_group_name_override) {
free((void *) tracing_group_name);
}
if (tracing_group_name_override) {
free((void *) tracing_group_name);
}
+ fd_tracker_log(the_fd_tracker);
}
/*
}
/*
@@
-3968,6
+3981,7
@@
static int create_relay_conn_pipe(void)
*/
int main(int argc, char **argv)
{
*/
int main(int argc, char **argv)
{
+ bool thread_is_rcu_registered = false;
int ret = 0, retval = 0;
void *status;
int ret = 0, retval = 0;
void *status;
@@
-4028,23
+4042,12
@@
int main(int argc, char **argv)
/* Daemonize */
if (opt_daemon || opt_background) {
/* Daemonize */
if (opt_daemon || opt_background) {
- int i;
-
ret = lttng_daemonize(&child_ppid, &recv_child_signal,
!opt_background);
if (ret < 0) {
retval = -1;
goto exit_options;
}
ret = lttng_daemonize(&child_ppid, &recv_child_signal,
!opt_background);
if (ret < 0) {
retval = -1;
goto exit_options;
}
-
- /*
- * We are in the child. Make sure all other file
- * descriptors are closed, in case we are called with
- * more opened file descriptors than the standard ones.
- */
- for (i = 3; i < sysconf(_SC_OPEN_MAX); i++) {
- (void) close(i);
- }
}
if (opt_working_directory) {
}
if (opt_working_directory) {
@@
-4059,7
+4062,22
@@
int main(int argc, char **argv)
if (!sessiond_trace_chunk_registry) {
ERR("Failed to initialize session daemon trace chunk registry");
retval = -1;
if (!sessiond_trace_chunk_registry) {
ERR("Failed to initialize session daemon trace chunk registry");
retval = -1;
- goto exit_sessiond_trace_chunk_registry;
+ goto exit_options;
+ }
+
+ /*
+ * The RCU thread registration (and use, through the fd-tracker's
+ * creation) is done after the daemonization to allow us to not
+ * deal with liburcu's fork() management as the call RCU needs to
+ * be restored.
+ */
+ rcu_register_thread();
+ thread_is_rcu_registered = true;
+
+ the_fd_tracker = fd_tracker_create(lttng_opt_fd_cap);
+ if (!the_fd_tracker) {
+ retval = -1;
+ goto exit_options;
}
/* Initialize thread health monitoring */
}
/* Initialize thread health monitoring */
@@
-4067,19
+4085,19
@@
int main(int argc, char **argv)
if (!health_relayd) {
PERROR("health_app_create error");
retval = -1;
if (!health_relayd) {
PERROR("health_app_create error");
retval = -1;
- goto exit_
health_app_create
;
+ goto exit_
options
;
}
/* Create thread quit pipe */
if (init_thread_quit_pipe()) {
retval = -1;
}
/* Create thread quit pipe */
if (init_thread_quit_pipe()) {
retval = -1;
- goto exit_
init_data
;
+ goto exit_
options
;
}
/* Setup the thread apps communication pipe. */
if (create_relay_conn_pipe()) {
retval = -1;
}
/* Setup the thread apps communication pipe. */
if (create_relay_conn_pipe()) {
retval = -1;
- goto exit_
init_data
;
+ goto exit_
options
;
}
/* Init relay command queue. */
}
/* Init relay command queue. */
@@
-4093,27
+4111,27
@@
int main(int argc, char **argv)
sessions_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!sessions_ht) {
retval = -1;
sessions_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!sessions_ht) {
retval = -1;
- goto exit_
init_data
;
+ goto exit_
options
;
}
/* tables of streams indexed by stream ID */
relay_streams_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!relay_streams_ht) {
retval = -1;
}
/* tables of streams indexed by stream ID */
relay_streams_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!relay_streams_ht) {
retval = -1;
- goto exit_
init_data
;
+ goto exit_
options
;
}
/* tables of streams indexed by stream ID */
viewer_streams_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!viewer_streams_ht) {
retval = -1;
}
/* tables of streams indexed by stream ID */
viewer_streams_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!viewer_streams_ht) {
retval = -1;
- goto exit_
init_data
;
+ goto exit_
options
;
}
ret = utils_create_pipe(health_quit_pipe);
if (ret) {
retval = -1;
}
ret = utils_create_pipe(health_quit_pipe);
if (ret) {
retval = -1;
- goto exit_
health_quit_pipe
;
+ goto exit_
options
;
}
/* Create thread to manage the client socket */
}
/* Create thread to manage the client socket */
@@
-4123,7
+4141,7
@@
int main(int argc, char **argv)
errno = ret;
PERROR("pthread_create health");
retval = -1;
errno = ret;
PERROR("pthread_create health");
retval = -1;
- goto exit_
health_thread
;
+ goto exit_
options
;
}
/* Setup the dispatcher thread */
}
/* Setup the dispatcher thread */
@@
-4204,16
+4222,6
@@
exit_dispatcher_thread:
PERROR("pthread_join health_thread");
retval = -1;
}
PERROR("pthread_join health_thread");
retval = -1;
}
-exit_health_thread:
-
- utils_close_pipe(health_quit_pipe);
-exit_health_quit_pipe:
-
-exit_init_data:
- health_app_destroy(health_relayd);
- sessiond_trace_chunk_registry_destroy(sessiond_trace_chunk_registry);
-exit_health_app_create:
-exit_sessiond_trace_chunk_registry:
exit_options:
/*
* Wait for all pending call_rcu work to complete before tearing
exit_options:
/*
* Wait for all pending call_rcu work to complete before tearing
@@
-4226,6
+4234,10
@@
exit_options:
/* Ensure all prior call_rcu are done. */
rcu_barrier();
/* Ensure all prior call_rcu are done. */
rcu_barrier();
+ if (thread_is_rcu_registered) {
+ rcu_unregister_thread();
+ }
+
if (!retval) {
exit(EXIT_SUCCESS);
} else {
if (!retval) {
exit(EXIT_SUCCESS);
} else {
This page took
0.027767 seconds
and
5
git commands to generate.