/*
- * Copyright (C) 2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@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.
*/
-#define _GNU_SOURCE
+#define _LGPL_SOURCE
#include <fcntl.h>
#include <getopt.h>
#include <grp.h>
#include <poll.h>
#include <unistd.h>
#include <sys/mman.h>
-#include <assert.h>
-#include <config.h>
#include <urcu/compiler.h>
#include <ulimit.h>
#include <inttypes.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/sessiond-comm/sessiond-comm.h>
#include <common/utils.h>
sock = lttcomm_create_unix_sock(health_unix_sock_path);
if (sock < 0) {
ERR("Unable to create health check Unix socket");
- ret = -1;
+ err = -1;
goto error;
}
is_root = !getuid();
if (is_root) {
/* lttng health client socket path permissions */
- ret = chown(health_unix_sock_path, 0,
- utils_get_group_id(tracing_group_name));
+ gid_t gid;
+
+ ret = utils_get_group_id(tracing_group_name, true, &gid);
+ if (ret) {
+ /* Default to root group. */
+ gid = 0;
+ }
+
+ ret = chown(health_unix_sock_path, 0, gid);
if (ret < 0) {
ERR("Unable to set group on %s", health_unix_sock_path);
PERROR("chown");
- ret = -1;
+ err = -1;
goto error;
}
if (ret < 0) {
ERR("Unable to set permissions on %s", health_unix_sock_path);
PERROR("chmod");
- ret = -1;
+ err = -1;
goto error;
}
}
/* Event on the registration socket */
if (pollfd == sock) {
- if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) {
+ if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)
+ && !(revents & LPOLLIN)) {
ERR("Health socket poll error");
goto error;
}
rcu_thread_online();
- assert(msg.cmd == HEALTH_CMD_CHECK);
+ LTTNG_ASSERT(msg.cmd == HEALTH_CMD_CHECK);
- reply.ret_code = 0;
+ memset(&reply, 0, sizeof(reply));
for (i = 0; i < NR_HEALTH_CONSUMERD_TYPES; i++) {
/*
* health_check_state return 0 if thread is in
}
}
- DBG2("Health check return value %" PRIx64, reply.ret_code);
+ DBG("Health check return value %" PRIx64, reply.ret_code);
ret = send_unix_sock(new_sock, (void *) &reply, sizeof(reply));
if (ret < 0) {