projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: poll and epoll fd set reallocation
[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 8a1f753114bfe3bfaa8cd5629ea5c7e199c29aab..6f8f1486ca60de5d958352868b9912ddcbdcf24f 100644
(file)
--- a/
src/bin/lttng-sessiond/main.c
+++ b/
src/bin/lttng-sessiond/main.c
@@
-461,7
+461,7
@@
static void cleanup(void)
static int send_unix_sock(int sock, void *buf, size_t len)
{
/* Check valid length */
static int send_unix_sock(int sock, void *buf, size_t len)
{
/* Check valid length */
- if (len
<
= 0) {
+ if (len
=
= 0) {
return -1;
}
return -1;
}
@@
-689,34
+689,36
@@
static void *thread_manage_kernel(void *data)
char tmp;
struct lttng_poll_event events;
char tmp;
struct lttng_poll_event events;
- DBG("Thread manage kernel started");
+ DBG("
[thread]
Thread manage kernel started");
- testpoint(thread_manage_kernel);
+ if (testpoint(thread_manage_kernel)) {
+ goto error_testpoint;
+ }
health_code_update(&health_thread_kernel);
health_code_update(&health_thread_kernel);
- testpoint(thread_manage_kernel_before_loop);
-
- ret = create_thread_poll_set(&events, 2);
- if (ret < 0) {
- goto error_poll_create;
- }
-
- ret = lttng_poll_add(&events, kernel_poll_pipe[0], LPOLLIN);
- if (ret < 0) {
- goto error;
+ if (testpoint(thread_manage_kernel_before_loop)) {
+ goto error_testpoint;
}
while (1) {
health_code_update(&health_thread_kernel);
if (update_poll_flag == 1) {
}
while (1) {
health_code_update(&health_thread_kernel);
if (update_poll_flag == 1) {
- /*
- * Reset number of fd in the poll set. Always 2 since there is the thread
- * quit pipe and the kernel pipe.
- */
- events.nb_fd = 2;
+ /* Clean events object. We are about to populate it again. */
+ lttng_poll_clean(&events);
+
+ ret = create_thread_poll_set(&events, 2);
+ if (ret < 0) {
+ goto error_poll_create;
+ }
+ ret = lttng_poll_add(&events, kernel_poll_pipe[0], LPOLLIN);
+ if (ret < 0) {
+ goto error;
+ }
+
+ /* This will add the available kernel channel if any. */
ret = update_kernel_poll(&events);
if (ret < 0) {
goto error;
ret = update_kernel_poll(&events);
if (ret < 0) {
goto error;
@@
-724,12
+726,7
@@
static void *thread_manage_kernel(void *data)
update_poll_flag = 0;
}
update_poll_flag = 0;
}
- nb_fd = LTTNG_POLL_GETNB(&events);
-
- DBG("Thread kernel polling on %d fds", nb_fd);
-
- /* Zeroed the poll events */
- lttng_poll_reset(&events);
+ DBG("Thread kernel polling on %d fds", LTTNG_POLL_GETNB(&events));
/* Poll infinite value of time */
restart:
/* Poll infinite value of time */
restart:
@@
-751,6
+748,8
@@
static void *thread_manage_kernel(void *data)
continue;
}
continue;
}
+ nb_fd = ret;
+
for (i = 0; i < nb_fd; i++) {
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
for (i = 0; i < nb_fd; i++) {
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
@@
-794,6
+793,7
@@
exit:
error:
lttng_poll_clean(&events);
error_poll_create:
error:
lttng_poll_clean(&events);
error_poll_create:
+error_testpoint:
utils_close_pipe(kernel_poll_pipe);
kernel_poll_pipe[0] = kernel_poll_pipe[1] = -1;
if (err) {
utils_close_pipe(kernel_poll_pipe);
kernel_poll_pipe[0] = kernel_poll_pipe[1] = -1;
if (err) {
@@
-881,15
+881,15
@@
static void *thread_manage_consumer(void *data)
goto error;
}
goto error;
}
- nb_fd = LTTNG_POLL_GETNB(&events);
-
health_code_update(&consumer_data->health);
/* Inifinite blocking call, waiting for transmission */
restart:
health_poll_update(&consumer_data->health);
health_code_update(&consumer_data->health);
/* Inifinite blocking call, waiting for transmission */
restart:
health_poll_update(&consumer_data->health);
- testpoint(thread_manage_consumer);
+ if (testpoint(thread_manage_consumer)) {
+ goto error;
+ }
ret = lttng_poll_wait(&events, -1);
health_poll_update(&consumer_data->health);
ret = lttng_poll_wait(&events, -1);
health_poll_update(&consumer_data->health);
@@
-903,6
+903,8
@@
restart:
goto error;
}
goto error;
}
+ nb_fd = ret;
+
for (i = 0; i < nb_fd; i++) {
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
for (i = 0; i < nb_fd; i++) {
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
@@
-980,9
+982,6
@@
restart:
health_code_update(&consumer_data->health);
health_code_update(&consumer_data->health);
- /* Update number of fd */
- nb_fd = LTTNG_POLL_GETNB(&events);
-
/* Inifinite blocking call, waiting for transmission */
restart_poll:
health_poll_update(&consumer_data->health);
/* Inifinite blocking call, waiting for transmission */
restart_poll:
health_poll_update(&consumer_data->health);
@@
-998,6
+997,8
@@
restart_poll:
goto error;
}
goto error;
}
+ nb_fd = ret;
+
for (i = 0; i < nb_fd; i++) {
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
for (i = 0; i < nb_fd; i++) {
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
@@
-1093,11
+1094,13
@@
static void *thread_manage_apps(void *data)
DBG("[thread] Manage application started");
DBG("[thread] Manage application started");
- testpoint(thread_manage_apps);
-
rcu_register_thread();
rcu_thread_online();
rcu_register_thread();
rcu_thread_online();
+ if (testpoint(thread_manage_apps)) {
+ goto error_testpoint;
+ }
+
health_code_update(&health_thread_app_manage);
ret = create_thread_poll_set(&events, 2);
health_code_update(&health_thread_app_manage);
ret = create_thread_poll_set(&events, 2);
@@
-1110,17
+1113,14
@@
static void *thread_manage_apps(void *data)
goto error;
}
goto error;
}
- testpoint(thread_manage_apps_before_loop);
+ if (testpoint(thread_manage_apps_before_loop)) {
+ goto error;
+ }
health_code_update(&health_thread_app_manage);
while (1) {
health_code_update(&health_thread_app_manage);
while (1) {
- /* Zeroed the events structure */
- lttng_poll_reset(&events);
-
- nb_fd = LTTNG_POLL_GETNB(&events);
-
- DBG("Apps thread polling on %d fds", nb_fd);
+ DBG("Apps thread polling on %d fds", LTTNG_POLL_GETNB(&events));
/* Inifinite blocking call, waiting for transmission */
restart:
/* Inifinite blocking call, waiting for transmission */
restart:
@@
-1137,6
+1137,8
@@
static void *thread_manage_apps(void *data)
goto error;
}
goto error;
}
+ nb_fd = ret;
+
for (i = 0; i < nb_fd; i++) {
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
for (i = 0; i < nb_fd; i++) {
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
@@
-1250,6
+1252,7
@@
exit:
error:
lttng_poll_clean(&events);
error_poll_create:
error:
lttng_poll_clean(&events);
error_poll_create:
+error_testpoint:
utils_close_pipe(apps_cmd_pipe);
apps_cmd_pipe[0] = apps_cmd_pipe[1] = -1;
utils_close_pipe(apps_cmd_pipe);
apps_cmd_pipe[0] = apps_cmd_pipe[1] = -1;
@@
-1358,7
+1361,9
@@
static void *thread_registration_apps(void *data)
DBG("[thread] Manage application registration started");
DBG("[thread] Manage application registration started");
- testpoint(thread_registration_apps);
+ if (testpoint(thread_registration_apps)) {
+ goto error_testpoint;
+ }
ret = lttcomm_listen_unix_sock(apps_sock);
if (ret < 0) {
ret = lttcomm_listen_unix_sock(apps_sock);
if (ret < 0) {
@@
-1391,8
+1396,6
@@
static void *thread_registration_apps(void *data)
while (1) {
DBG("Accepting application registration");
while (1) {
DBG("Accepting application registration");
- nb_fd = LTTNG_POLL_GETNB(&events);
-
/* Inifinite blocking call, waiting for transmission */
restart:
health_poll_update(&health_thread_app_reg);
/* Inifinite blocking call, waiting for transmission */
restart:
health_poll_update(&health_thread_app_reg);
@@
-1408,6
+1411,8
@@
static void *thread_registration_apps(void *data)
goto error;
}
goto error;
}
+ nb_fd = ret;
+
for (i = 0; i < nb_fd; i++) {
health_code_update(&health_thread_app_reg);
for (i = 0; i < nb_fd; i++) {
health_code_update(&health_thread_app_reg);
@@
-1513,7
+1518,6
@@
error:
health_error(&health_thread_app_reg);
ERR("Health error occurred in %s", __func__);
}
health_error(&health_thread_app_reg);
ERR("Health error occurred in %s", __func__);
}
- health_exit(&health_thread_app_reg);
/* Notify that the registration thread is gone */
notify_ust_apps(0);
/* Notify that the registration thread is gone */
notify_ust_apps(0);
@@
-1537,7
+1541,9
@@
error_poll_add:
lttng_poll_clean(&events);
error_listen:
error_create_poll:
lttng_poll_clean(&events);
error_listen:
error_create_poll:
+error_testpoint:
DBG("UST Registration thread cleanup complete");
DBG("UST Registration thread cleanup complete");
+ health_exit(&health_thread_app_reg);
return NULL;
}
return NULL;
}
@@
-1669,10
+1675,10
@@
error:
static int join_consumer_thread(struct consumer_data *consumer_data)
{
void *status;
static int join_consumer_thread(struct consumer_data *consumer_data)
{
void *status;
- int ret;
/* Consumer pid must be a real one. */
if (consumer_data->pid > 0) {
/* Consumer pid must be a real one. */
if (consumer_data->pid > 0) {
+ int ret;
ret = kill(consumer_data->pid, SIGTERM);
if (ret) {
ERR("Error killing consumer daemon");
ret = kill(consumer_data->pid, SIGTERM);
if (ret) {
ERR("Error killing consumer daemon");
@@
-1851,7
+1857,7
@@
error:
*/
static int start_consumerd(struct consumer_data *consumer_data)
{
*/
static int start_consumerd(struct consumer_data *consumer_data)
{
- int ret
, err
;
+ int ret;
/*
* Set the listen() state on the socket since there is a possible race
/*
* Set the listen() state on the socket since there is a possible race
@@
-1894,6
+1900,8
@@
end:
error:
/* Cleanup already created socket on error. */
if (consumer_data->err_sock >= 0) {
error:
/* Cleanup already created socket on error. */
if (consumer_data->err_sock >= 0) {
+ int err;
+
err = close(consumer_data->err_sock);
if (err < 0) {
PERROR("close consumer data error socket");
err = close(consumer_data->err_sock);
if (err < 0) {
PERROR("close consumer data error socket");
@@
-2967,8
+2975,6
@@
static void *thread_manage_health(void *data)
while (1) {
DBG("Health check ready");
while (1) {
DBG("Health check ready");
- nb_fd = LTTNG_POLL_GETNB(&events);
-
/* Inifinite blocking call, waiting for transmission */
restart:
ret = lttng_poll_wait(&events, -1);
/* Inifinite blocking call, waiting for transmission */
restart:
ret = lttng_poll_wait(&events, -1);
@@
-2982,6
+2988,8
@@
restart:
goto error;
}
goto error;
}
+ nb_fd = ret;
+
for (i = 0; i < nb_fd; i++) {
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
for (i = 0; i < nb_fd; i++) {
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
@@
-3122,10
+3130,12
@@
static void *thread_manage_clients(void *data)
DBG("[thread] Manage client started");
DBG("[thread] Manage client started");
- testpoint(thread_manage_clients);
-
rcu_register_thread();
rcu_register_thread();
+ if (testpoint(thread_manage_clients)) {
+ goto error_testpoint;
+ }
+
health_code_update(&health_thread_cmd);
ret = lttcomm_listen_unix_sock(client_sock);
health_code_update(&health_thread_cmd);
ret = lttcomm_listen_unix_sock(client_sock);
@@
-3155,15
+3165,15
@@
static void *thread_manage_clients(void *data)
kill(ppid, SIGUSR1);
}
kill(ppid, SIGUSR1);
}
- testpoint(thread_manage_clients_before_loop);
+ if (testpoint(thread_manage_clients_before_loop)) {
+ goto error;
+ }
health_code_update(&health_thread_cmd);
while (1) {
DBG("Accepting client command ...");
health_code_update(&health_thread_cmd);
while (1) {
DBG("Accepting client command ...");
- nb_fd = LTTNG_POLL_GETNB(&events);
-
/* Inifinite blocking call, waiting for transmission */
restart:
health_poll_update(&health_thread_cmd);
/* Inifinite blocking call, waiting for transmission */
restart:
health_poll_update(&health_thread_cmd);
@@
-3179,6
+3189,8
@@
static void *thread_manage_clients(void *data)
goto error;
}
goto error;
}
+ nb_fd = ret;
+
for (i = 0; i < nb_fd; i++) {
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
for (i = 0; i < nb_fd; i++) {
/* Fetch once the poll data */
revents = LTTNG_POLL_GETEV(&events, i);
@@
-3330,6
+3342,7
@@
error:
error_listen:
error_create_poll:
error_listen:
error_create_poll:
+error_testpoint:
unlink(client_unix_sock_path);
if (client_sock >= 0) {
ret = close(client_sock);
unlink(client_unix_sock_path);
if (client_sock >= 0) {
ret = close(client_sock);
@@
-3835,7
+3848,7
@@
int main(int argc, char **argv)
/* Parse arguments */
progname = argv[0];
/* Parse arguments */
progname = argv[0];
- if ((ret = parse_args(argc, argv)
< 0)
) {
+ if ((ret = parse_args(argc, argv)
) < 0
) {
goto error;
}
goto error;
}
This page took
0.029384 seconds
and
5
git commands to generate.