projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: use error code path instead of break when errors happen before execl
[lttng-tools.git]
/
src
/
bin
/
lttng-sessiond
/
main.c
diff --git
a/src/bin/lttng-sessiond/main.c
b/src/bin/lttng-sessiond/main.c
index 497f4ee97e7dea8cac8afa20a20f42130e00700a..80ca3d7c04e42704a325bb8b2aedfee1db0d7837 100644
(file)
--- a/
src/bin/lttng-sessiond/main.c
+++ b/
src/bin/lttng-sessiond/main.c
@@
-37,6
+37,7
@@
#include <sys/wait.h>
#include <urcu/uatomic.h>
#include <unistd.h>
#include <sys/wait.h>
#include <urcu/uatomic.h>
#include <unistd.h>
+#include <ctype.h>
#include <common/common.h>
#include <common/compat/socket.h>
#include <common/common.h>
#include <common/compat/socket.h>
@@
-563,8
+564,7
@@
static void wait_consumer(struct consumer_data *consumer_data)
ret = waitpid(consumer_data->pid, &status, 0);
if (ret == -1) {
PERROR("consumerd waitpid pid: %d", consumer_data->pid)
ret = waitpid(consumer_data->pid, &status, 0);
if (ret == -1) {
PERROR("consumerd waitpid pid: %d", consumer_data->pid)
- }
- if (!WIFEXITED(status)) {
+ } else if (!WIFEXITED(status)) {
ERR("consumerd termination with error: %d",
WEXITSTATUS(ret));
}
ERR("consumerd termination with error: %d",
WEXITSTATUS(ret));
}
@@
-759,12
+759,6
@@
static void sessiond_cleanup_options(void)
free(kmod_extra_probes_list);
run_as_destroy_worker();
free(kmod_extra_probes_list);
run_as_destroy_worker();
-
- /* <fun> */
- DBG("%c[%d;%dm*** assert failed :-) *** ==> %c[%dm%c[%d;%dm"
- "Matthew, BEET driven development works!%c[%dm",
- 27, 1, 31, 27, 0, 27, 1, 33, 27, 0);
- /* </fun> */
}
/*
}
/*
@@
-1356,7
+1350,6
@@
restart:
consumer_data->metadata_sock.lock = zmalloc(sizeof(pthread_mutex_t));
if (consumer_data->metadata_sock.lock == NULL) {
PERROR("zmalloc pthread mutex");
consumer_data->metadata_sock.lock = zmalloc(sizeof(pthread_mutex_t));
if (consumer_data->metadata_sock.lock == NULL) {
PERROR("zmalloc pthread mutex");
- ret = -1;
goto error;
}
pthread_mutex_init(consumer_data->metadata_sock.lock, NULL);
goto error;
}
pthread_mutex_init(consumer_data->metadata_sock.lock, NULL);
@@
-1861,6
+1854,8
@@
static void *thread_dispatch_ust_registration(void *data)
.count = 0,
};
.count = 0,
};
+ rcu_register_thread();
+
health_register(health_sessiond, HEALTH_SESSIOND_TYPE_APP_REG_DISPATCH);
if (testpoint(sessiond_thread_app_reg_dispatch)) {
health_register(health_sessiond, HEALTH_SESSIOND_TYPE_APP_REG_DISPATCH);
if (testpoint(sessiond_thread_app_reg_dispatch)) {
@@
-1873,12
+1868,16
@@
static void *thread_dispatch_ust_registration(void *data)
DBG("[thread] Dispatch UST command started");
DBG("[thread] Dispatch UST command started");
-
while (!CMM_LOAD_SHARED(dispatch_thread_exit)
) {
+
for (;;
) {
health_code_update();
/* Atomically prepare the queue futex */
futex_nto1_prepare(&ust_cmd_queue.futex);
health_code_update();
/* Atomically prepare the queue futex */
futex_nto1_prepare(&ust_cmd_queue.futex);
+ if (CMM_LOAD_SHARED(dispatch_thread_exit)) {
+ break;
+ }
+
do {
struct ust_app *app = NULL;
ust_cmd = NULL;
do {
struct ust_app *app = NULL;
ust_cmd = NULL;
@@
-2094,6
+2093,7
@@
error_testpoint:
ERR("Health error occurred in %s", __func__);
}
health_unregister(health_sessiond);
ERR("Health error occurred in %s", __func__);
}
health_unregister(health_sessiond);
+ rcu_unregister_thread();
return NULL;
}
return NULL;
}
@@
-2201,10
+2201,12
@@
static void *thread_registration_apps(void *data)
* lttcomm_setsockopt_snd_timeout expect msec as
* parameter.
*/
* lttcomm_setsockopt_snd_timeout expect msec as
* parameter.
*/
- (void) lttcomm_setsockopt_rcv_timeout(sock,
- app_socket_timeout * 1000);
- (void) lttcomm_setsockopt_snd_timeout(sock,
- app_socket_timeout * 1000);
+ if (app_socket_timeout >= 0) {
+ (void) lttcomm_setsockopt_rcv_timeout(sock,
+ app_socket_timeout * 1000);
+ (void) lttcomm_setsockopt_snd_timeout(sock,
+ app_socket_timeout * 1000);
+ }
/*
* Set the CLOEXEC flag. Return code is useless because
/*
* Set the CLOEXEC flag. Return code is useless because
@@
-2365,8
+2367,8
@@
static int spawn_consumer_thread(struct consumer_data *consumer_data)
goto error;
}
goto error;
}
- ret = pthread_create(&consumer_data->thread,
NULL, thread_manage_consumer
,
- consumer_data);
+ ret = pthread_create(&consumer_data->thread,
default_pthread_attr()
,
+
thread_manage_consumer,
consumer_data);
if (ret) {
errno = ret;
PERROR("pthread_create consumer");
if (ret) {
errno = ret;
PERROR("pthread_create consumer");
@@
-2378,7
+2380,7
@@
static int spawn_consumer_thread(struct consumer_data *consumer_data)
pthread_mutex_lock(&consumer_data->cond_mutex);
/* Get time for sem_timedwait absolute timeout */
pthread_mutex_lock(&consumer_data->cond_mutex);
/* Get time for sem_timedwait absolute timeout */
- clock_ret = clock_gettime(CLOCK_MONOTONIC, &timeout);
+ clock_ret =
lttng_
clock_gettime(CLOCK_MONOTONIC, &timeout);
/*
* Set the timeout for the condition timed wait even if the clock gettime
* call fails since we might loop on that call and we want to avoid to
/*
* Set the timeout for the condition timed wait even if the clock gettime
* call fails since we might loop on that call and we want to avoid to
@@
-2524,7
+2526,7
@@
static pid_t spawn_consumerd(struct consumer_data *consumer_data)
} else {
DBG("Could not find any valid consumerd executable");
ret = -EINVAL;
} else {
DBG("Could not find any valid consumerd executable");
ret = -EINVAL;
-
break
;
+
goto error
;
}
DBG("Using kernel consumer at: %s", consumer_to_use);
ret = execl(consumer_to_use,
}
DBG("Using kernel consumer at: %s", consumer_to_use);
ret = execl(consumer_to_use,
@@
-3003,7
+3005,8
@@
static int process_client_msg(struct command_ctx *cmd_ctx, int sock,
case LTTNG_SNAPSHOT_RECORD:
case LTTNG_SAVE_SESSION:
case LTTNG_SET_SESSION_SHM_PATH:
case LTTNG_SNAPSHOT_RECORD:
case LTTNG_SAVE_SESSION:
case LTTNG_SET_SESSION_SHM_PATH:
- case LTTNG_METADATA_REGENERATE:
+ case LTTNG_REGENERATE_METADATA:
+ case LTTNG_REGENERATE_STATEDUMP:
need_domain = 0;
break;
default:
need_domain = 0;
break;
default:
@@
-3061,7
+3064,6
@@
static int process_client_msg(struct command_ctx *cmd_ctx, int sock,
case LTTNG_CREATE_SESSION:
case LTTNG_CREATE_SESSION_SNAPSHOT:
case LTTNG_CREATE_SESSION_LIVE:
case LTTNG_CREATE_SESSION:
case LTTNG_CREATE_SESSION_SNAPSHOT:
case LTTNG_CREATE_SESSION_LIVE:
- case LTTNG_CALIBRATE:
case LTTNG_LIST_SESSIONS:
case LTTNG_LIST_TRACEPOINTS:
case LTTNG_LIST_SYSCALLS:
case LTTNG_LIST_SESSIONS:
case LTTNG_LIST_TRACEPOINTS:
case LTTNG_LIST_SYSCALLS:
@@
-3903,12
+3905,6
@@
error_add_context:
ret = LTTNG_OK;
break;
}
ret = LTTNG_OK;
break;
}
- case LTTNG_CALIBRATE:
- {
- ret = cmd_calibrate(cmd_ctx->lsm->domain.type,
- &cmd_ctx->lsm->u.calibrate);
- break;
- }
case LTTNG_REGISTER_CONSUMER:
{
struct consumer_data *cdata;
case LTTNG_REGISTER_CONSUMER:
{
struct consumer_data *cdata;
@@
-4114,9
+4110,14
@@
error_add_context:
cmd_ctx->lsm->u.set_shm_path.shm_path);
break;
}
cmd_ctx->lsm->u.set_shm_path.shm_path);
break;
}
- case LTTNG_
METADATA_REGENERATE
:
+ case LTTNG_
REGENERATE_METADATA
:
{
{
- ret = cmd_metadata_regenerate(cmd_ctx->session);
+ ret = cmd_regenerate_metadata(cmd_ctx->session);
+ break;
+ }
+ case LTTNG_REGENERATE_STATEDUMP:
+ {
+ ret = cmd_regenerate_statedump(cmd_ctx->session);
break;
}
default:
break;
}
default:
@@
-4285,7
+4286,6
@@
restart:
if (ret) {
PERROR("close");
}
if (ret) {
PERROR("close");
}
- new_sock = -1;
continue;
}
continue;
}
@@
-4314,7
+4314,6
@@
restart:
if (ret) {
PERROR("close");
}
if (ret) {
PERROR("close");
}
- new_sock = -1;
}
exit:
}
exit:
@@
-4332,7
+4331,7
@@
error:
}
lttng_poll_clean(&events);
}
lttng_poll_clean(&events);
-
+ stop_threads();
rcu_unregister_thread();
return NULL;
}
rcu_unregister_thread();
return NULL;
}
@@
-5370,9
+5369,6
@@
error:
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");
stop_threads();
case SIGINT:
DBG("SIGINT caught");
stop_threads();
@@
-5404,9
+5400,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;
@@
-5417,12
+5414,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;
}
@@
-5979,7
+5977,7
@@
int main(int argc, char **argv)
load_info->path = opt_load_session_path;
/* Create health-check thread */
load_info->path = opt_load_session_path;
/* Create health-check thread */
- 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;
@@
-5989,7
+5987,7
@@
int main(int argc, char **argv)
}
/* Create thread to manage the client socket */
}
/* Create thread to manage the client socket */
- ret = pthread_create(&client_thread,
NULL
,
+ ret = pthread_create(&client_thread,
default_pthread_attr()
,
thread_manage_clients, (void *) NULL);
if (ret) {
errno = ret;
thread_manage_clients, (void *) NULL);
if (ret) {
errno = ret;
@@
-5999,7
+5997,7
@@
int main(int argc, char **argv)
}
/* Create thread to dispatch registration */
}
/* Create thread to dispatch registration */
- ret = pthread_create(&dispatch_thread,
NULL
,
+ ret = pthread_create(&dispatch_thread,
default_pthread_attr()
,
thread_dispatch_ust_registration, (void *) NULL);
if (ret) {
errno = ret;
thread_dispatch_ust_registration, (void *) NULL);
if (ret) {
errno = ret;
@@
-6009,7
+6007,7
@@
int main(int argc, char **argv)
}
/* Create thread to manage application registration. */
}
/* Create thread to manage application registration. */
- ret = pthread_create(®_apps_thread,
NULL
,
+ ret = pthread_create(®_apps_thread,
default_pthread_attr()
,
thread_registration_apps, (void *) NULL);
if (ret) {
errno = ret;
thread_registration_apps, (void *) NULL);
if (ret) {
errno = ret;
@@
-6019,7
+6017,7
@@
int main(int argc, char **argv)
}
/* Create thread to manage application socket */
}
/* Create thread to manage application socket */
- ret = pthread_create(&apps_thread,
NULL
,
+ ret = pthread_create(&apps_thread,
default_pthread_attr()
,
thread_manage_apps, (void *) NULL);
if (ret) {
errno = ret;
thread_manage_apps, (void *) NULL);
if (ret) {
errno = ret;
@@
-6029,7
+6027,7
@@
int main(int argc, char **argv)
}
/* Create thread to manage application notify socket */
}
/* Create thread to manage application notify socket */
- ret = pthread_create(&apps_notify_thread,
NULL
,
+ ret = pthread_create(&apps_notify_thread,
default_pthread_attr()
,
ust_thread_manage_notify, (void *) NULL);
if (ret) {
errno = ret;
ust_thread_manage_notify, (void *) NULL);
if (ret) {
errno = ret;
@@
-6039,7
+6037,7
@@
int main(int argc, char **argv)
}
/* Create agent registration thread. */
}
/* Create agent registration thread. */
- ret = pthread_create(&agent_reg_thread,
NULL
,
+ ret = pthread_create(&agent_reg_thread,
default_pthread_attr()
,
agent_thread_manage_registration, (void *) NULL);
if (ret) {
errno = ret;
agent_thread_manage_registration, (void *) NULL);
if (ret) {
errno = ret;
@@
-6051,7
+6049,7
@@
int main(int argc, char **argv)
/* Don't start this thread if kernel tracing is not requested nor root */
if (is_root && !opt_no_kernel) {
/* Create kernel thread to manage kernel event */
/* Don't start this thread if kernel tracing is not requested nor root */
if (is_root && !opt_no_kernel) {
/* Create kernel thread to manage kernel event */
- ret = pthread_create(&kernel_thread,
NULL
,
+ ret = pthread_create(&kernel_thread,
default_pthread_attr()
,
thread_manage_kernel, (void *) NULL);
if (ret) {
errno = ret;
thread_manage_kernel, (void *) NULL);
if (ret) {
errno = ret;
@@
-6062,8
+6060,8
@@
int main(int argc, char **argv)
}
/* Create session loading thread. */
}
/* Create session loading thread. */
- ret = pthread_create(&load_session_thread,
NULL, thread_load_session
,
- load_info);
+ ret = pthread_create(&load_session_thread,
default_pthread_attr()
,
+
thread_load_session,
load_info);
if (ret) {
errno = ret;
PERROR("pthread_create load_session_thread");
if (ret) {
errno = ret;
PERROR("pthread_create load_session_thread");
@@
-6155,6
+6153,12
@@
exit_client:
exit_health:
exit_init_data:
exit_health:
exit_init_data:
+ /*
+ * 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();
/*
* sessiond_cleanup() is called when no other thread is running, except
* the ht_cleanup thread, which is needed to destroy the hash tables.
/*
* sessiond_cleanup() is called when no other thread is running, except
* the ht_cleanup thread, which is needed to destroy the hash tables.
This page took
0.036947 seconds
and
4
git commands to generate.