Fix: sessiond: fix memory leak in receive_lttng_trigger
[lttng-tools.git] / src / bin / lttng-sessiond / register.c
index d57a564cf6ec6f38ec5210f9a7397931eedc695a..bd6cd52dd5a1bc79e4fa0d6da1ed1953e4d30415 100644 (file)
@@ -1,20 +1,10 @@
 /*
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
- *                      Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *               2013 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2 only,
- * as published by the Free Software Foundation.
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include <stddef.h>
@@ -22,6 +12,7 @@
 #include <urcu.h>
 #include <common/futex.h>
 #include <common/macros.h>
+#include <common/shm.h>
 #include <common/utils.h>
 #include <sys/stat.h>
 
@@ -30,7 +21,6 @@
 #include "testpoint.h"
 #include "health-sessiond.h"
 #include "fd-limit.h"
-#include "shm.h"
 #include "utils.h"
 #include "thread.h"
 
@@ -52,9 +42,11 @@ static int create_application_socket(void)
        const mode_t old_umask = umask(0);
 
        /* Create the application unix socket */
-       apps_sock = lttcomm_create_unix_sock(config.apps_unix_sock_path.value);
+       apps_sock = lttcomm_create_unix_sock(
+                       the_config.apps_unix_sock_path.value);
        if (apps_sock < 0) {
-               ERR("Create unix sock failed: %s", config.apps_unix_sock_path.value);
+               ERR("Create unix sock failed: %s",
+                               the_config.apps_unix_sock_path.value);
                ret = -1;
                goto end;
        }
@@ -68,11 +60,12 @@ static int create_application_socket(void)
        }
 
        /* File permission MUST be 666 */
-       ret = chmod(config.apps_unix_sock_path.value,
-                       S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
+       ret = chmod(the_config.apps_unix_sock_path.value,
+                       S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
+                                       S_IWOTH);
        if (ret < 0) {
                PERROR("Set file permissions failed on %s",
-                               config.apps_unix_sock_path.value);
+                               the_config.apps_unix_sock_path.value);
                goto error_close_socket;
        }
 
@@ -100,7 +93,8 @@ static int notify_ust_apps(int active, bool is_root)
        DBG("Notifying applications of session daemon state: %d", active);
 
        /* See shm.c for this call implying mmap, shm and futex calls */
-       wait_shm_mmap = shm_ust_get_mmap(config.wait_shm_path.value, is_root);
+       wait_shm_mmap = shm_ust_get_mmap(
+                       the_config.wait_shm_path.value, is_root);
        if (wait_shm_mmap == NULL) {
                goto error;
        }
@@ -176,7 +170,7 @@ static void *thread_application_registration(void *data)
        DBG("[thread] Manage application registration started");
 
        pthread_cleanup_push(thread_init_cleanup, thread_state);
-       health_register(health_sessiond, HEALTH_SESSIOND_TYPE_APP_REG);
+       health_register(the_health_sessiond, HEALTH_SESSIOND_TYPE_APP_REG);
 
        ret = lttcomm_listen_unix_sock(application_socket);
        if (ret < 0) {
@@ -257,11 +251,11 @@ static void *thread_application_registration(void *data)
                                         * lttcomm_setsockopt_snd_timeout expect msec as
                                         * parameter.
                                         */
-                                       if (config.app_socket_timeout >= 0) {
+                                       if (the_config.app_socket_timeout >= 0) {
                                                (void) lttcomm_setsockopt_rcv_timeout(sock,
-                                                               config.app_socket_timeout * 1000);
+                                                               the_config.app_socket_timeout * 1000);
                                                (void) lttcomm_setsockopt_snd_timeout(sock,
-                                                               config.app_socket_timeout * 1000);
+                                                               the_config.app_socket_timeout * 1000);
                                        }
 
                                        /*
@@ -363,7 +357,7 @@ error:
                }
                lttng_fd_put(LTTNG_FD_APPS, 1);
        }
-       unlink(config.apps_unix_sock_path.value);
+       unlink(the_config.apps_unix_sock_path.value);
 
 error_poll_add:
        lttng_poll_clean(&events);
@@ -374,7 +368,7 @@ error_create_poll:
                health_error();
                ERR("Health error occurred in %s", __func__);
        }
-       health_unregister(health_sessiond);
+       health_unregister(the_health_sessiond);
        return NULL;
 }
 
This page took 0.025018 seconds and 4 git commands to generate.