projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: main.c client/apps sockets and kernel_trace_fd close(0)
[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 3cb970c06e21c62c50b42a2e7466ead067a493f9..efe2143ddcb101065200b040a5e3f7309ba31491 100644
(file)
--- a/
src/bin/lttng-sessiond/main.c
+++ b/
src/bin/lttng-sessiond/main.c
@@
-122,9
+122,9
@@
static char client_unix_sock_path[PATH_MAX];
static char wait_shm_path[PATH_MAX];
/* Sockets and FDs */
static char wait_shm_path[PATH_MAX];
/* Sockets and FDs */
-static int client_sock;
-static int apps_sock;
-static int kernel_tracer_fd;
+static int client_sock
= -1
;
+static int apps_sock
= -1
;
+static int kernel_tracer_fd
= -1
;
static int kernel_poll_pipe[2];
/*
static int kernel_poll_pipe[2];
/*
@@
-419,7
+419,9
@@
static void cleanup(void)
if (is_root && !opt_no_kernel) {
DBG2("Closing kernel fd");
if (is_root && !opt_no_kernel) {
DBG2("Closing kernel fd");
- close(kernel_tracer_fd);
+ if (kernel_tracer_fd >= 0) {
+ close(kernel_tracer_fd);
+ }
DBG("Unloading kernel modules");
modprobe_remove_lttng_all();
}
DBG("Unloading kernel modules");
modprobe_remove_lttng_all();
}
@@
-1281,7
+1283,7
@@
error:
*/
static void *thread_registration_apps(void *data)
{
*/
static void *thread_registration_apps(void *data)
{
- int sock =
0
, i, ret, pollfd;
+ int sock =
-1
, i, ret, pollfd;
uint32_t revents, nb_fd;
struct lttng_poll_event events;
/*
uint32_t revents, nb_fd;
struct lttng_poll_event events;
/*
@@
-1415,8
+1417,12
@@
error:
/* Notify that the registration thread is gone */
notify_ust_apps(0);
/* Notify that the registration thread is gone */
notify_ust_apps(0);
- close(apps_sock);
- close(sock);
+ if (apps_sock >= 0) {
+ close(apps_sock);
+ }
+ if (clock >= 0) {
+ close(sock);
+ }
unlink(apps_unix_sock_path);
lttng_poll_clean(&events);
unlink(apps_unix_sock_path);
lttng_poll_clean(&events);
@@
-1772,7
+1778,7
@@
error_open:
error:
WARN("No kernel tracer available");
error:
WARN("No kernel tracer available");
- kernel_tracer_fd =
0
;
+ kernel_tracer_fd =
-1
;
return LTTCOMM_KERN_NA;
}
return LTTCOMM_KERN_NA;
}
@@
-3249,7
+3255,7
@@
static int process_client_msg(struct command_ctx *cmd_ctx)
}
/* Kernel tracer check */
}
/* Kernel tracer check */
- if (kernel_tracer_fd ==
0
) {
+ if (kernel_tracer_fd ==
-1
) {
/* Basically, load kernel tracer modules */
ret = init_kernel_tracer();
if (ret != 0) {
/* Basically, load kernel tracer modules */
ret = init_kernel_tracer();
if (ret != 0) {
@@
-3589,7
+3595,7
@@
init_setup_error:
*/
static void *thread_manage_clients(void *data)
{
*/
static void *thread_manage_clients(void *data)
{
- int sock =
0
, ret, i, pollfd;
+ int sock =
-1
, ret, i, pollfd;
uint32_t revents, nb_fd;
struct command_ctx *cmd_ctx = NULL;
struct lttng_poll_event events;
uint32_t revents, nb_fd;
struct command_ctx *cmd_ctx = NULL;
struct lttng_poll_event events;
@@
-3747,8
+3753,12
@@
static void *thread_manage_clients(void *data)
error:
DBG("Client thread dying");
unlink(client_unix_sock_path);
error:
DBG("Client thread dying");
unlink(client_unix_sock_path);
- close(client_sock);
- close(sock);
+ if (sock >= 0) {
+ close(client_sock);
+ }
+ if (sock >= 0) {
+ close(sock);
+ }
lttng_poll_clean(&events);
clean_command_ctx(&cmd_ctx);
lttng_poll_clean(&events);
clean_command_ctx(&cmd_ctx);
This page took
0.024749 seconds
and
4
git commands to generate.