* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#define _GNU_SOURCE
#define _LGPL_SOURCE
#include <fcntl.h>
#include <getopt.h>
#include <unistd.h>
#include <sys/mman.h>
#include <assert.h>
-#include <config.h>
#include <urcu/compiler.h>
#include <ulimit.h>
#include <common/defaults.h>
#include <common/common.h>
-#include <common/consumer.h>
-#include <common/consumer-timer.h>
+#include <common/consumer/consumer.h>
+#include <common/consumer/consumer-timer.h>
#include <common/compat/poll.h>
#include <common/compat/getenv.h>
#include <common/sessiond-comm/sessiond-comm.h>
return;
}
- /*
- * Ignore SIGPIPE because it should not stop the consumer whenever a
- * SIGPIPE is catched through a FD operation.
- */
- if (sig == SIGPIPE) {
- return;
- }
-
if (ctx) {
lttng_consumer_should_exit(ctx);
}
return ret;
}
- sa.sa_handler = sighandler;
sa.sa_mask = sigset;
sa.sa_flags = 0;
+
+ sa.sa_handler = sighandler;
if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
PERROR("sigaction");
return ret;
return ret;
}
+ sa.sa_handler = SIG_IGN;
if ((ret = sigaction(SIGPIPE, &sa, NULL)) < 0) {
PERROR("sigaction");
return ret;
void *status;
struct lttng_consumer_local_data *tmp_ctx;
+ rcu_register_thread();
+
if (set_signal_handler()) {
retval = -1;
goto exit_set_signal_handler;
goto exit_health_consumerd_cleanup;
}
- /* Set up max poll set size */
- if (lttng_poll_set_max_size()) {
- retval = -1;
- goto exit_init_data;
- }
-
if (*command_sock_path == '\0') {
switch (opt_type) {
case LTTNG_CONSUMER_KERNEL:
}
/* 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;
cmm_smp_mb(); /* Read ready before following operations */
/* Create thread to manage channels */
- ret = pthread_create(&channel_thread, NULL,
+ ret = pthread_create(&channel_thread, default_pthread_attr(),
consumer_thread_channel_poll,
(void *) ctx);
if (ret) {
}
/* Create thread to manage the polling/writing of trace metadata */
- ret = pthread_create(&metadata_thread, NULL,
+ ret = pthread_create(&metadata_thread, default_pthread_attr(),
consumer_thread_metadata_poll,
(void *) ctx);
if (ret) {
}
/* Create thread to manage the polling/writing of trace data */
- ret = pthread_create(&data_thread, NULL, consumer_thread_data_poll,
- (void *) ctx);
+ ret = pthread_create(&data_thread, default_pthread_attr(),
+ consumer_thread_data_poll, (void *) ctx);
if (ret) {
errno = ret;
PERROR("pthread_create");
}
/* Create the thread to manage the receive of fd */
- ret = pthread_create(&sessiond_thread, NULL,
+ ret = pthread_create(&sessiond_thread, default_pthread_attr(),
consumer_thread_sessiond_poll,
(void *) ctx);
if (ret) {
* Create the thread to manage the UST metadata periodic timer and
* live timer.
*/
- ret = pthread_create(&metadata_timer_thread, NULL,
+ ret = pthread_create(&metadata_timer_thread, default_pthread_attr(),
consumer_timer_thread, (void *) ctx);
if (ret) {
errno = ret;
tmp_ctx = ctx;
ctx = NULL;
cmm_barrier(); /* Clear ctx for signal handler. */
+ /*
+ * 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();
lttng_consumer_destroy(tmp_ctx);
lttng_consumer_cleanup();
if (health_consumerd) {
health_app_destroy(health_consumerd);
}
-exit_health_consumerd_cleanup:
+ /* Ensure all prior call_rcu are done. */
+ rcu_barrier();
-exit_options:
+ run_as_destroy_worker();
+exit_health_consumerd_cleanup:
+exit_options:
exit_set_signal_handler:
- /* Ensure all prior call_rcu are done. */
- rcu_barrier();
+
+ rcu_unregister_thread();
if (!retval) {
exit(EXIT_SUCCESS);