/*
* SPDX-License-Identifier: LGPL-2.1-only
*
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
* Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*/
/*
* libust threads require the close-on-exec flag for all
* resources so it does not leak file descriptors upon exec.
- * SOCK_CLOEXEC is not used since it is linux specific.
*/
- fd = socket(PF_UNIX, SOCK_STREAM, 0);
+ fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (fd < 0) {
PERROR("socket");
ret = -errno;
WARN("Error setting connect socket send timeout");
}
}
- ret = fcntl(fd, F_SETFD, FD_CLOEXEC);
- if (ret < 0) {
- PERROR("fcntl");
- ret = -errno;
- goto error_fcntl;
- }
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
strncpy(sun.sun_path, pathname, sizeof(sun.sun_path));
sun.sun_path[sizeof(sun.sun_path) - 1] = '\0';
+ DBG("Connecting to '%s'", sun.sun_path);
ret = connect(fd, (struct sockaddr *) &sun, sizeof(sun));
if (ret < 0) {
/*
return fd;
error_connect:
-error_fcntl:
{
int closeret;
char recv_fd[CMSG_SPACE(sizeof_fds)];
struct msghdr msg;
char dummy;
- int i;
memset(&msg, 0, sizeof(msg));
msg.msg_controllen = sizeof(recv_fd);
do {
- ret = recvmsg(sock, &msg, 0);
+ ret = recvmsg(sock, &msg, MSG_CMSG_CLOEXEC);
} while (ret < 0 && errno == EINTR);
if (ret < 0) {
if (errno != EPIPE && errno != ECONNRESET) {
memcpy(fds, CMSG_DATA(cmsg), sizeof_fds);
- /* Set FD_CLOEXEC */
- for (i = 0; i < nb_fd; i++) {
- ret = fcntl(fds[i], F_SETFD, FD_CLOEXEC);
- if (ret < 0) {
- PERROR("fcntl failed to set FD_CLOEXEC on fd %d",
- fds[i]);
- }
- }
-
ret = nb_fd;
end:
return ret;
uint32_t uint16_t_alignment,
uint32_t uint32_t_alignment,
uint32_t uint64_t_alignment,
- uint32_t long_alignment)
+ uint32_t long_alignment,
+ const char *procname)
{
ssize_t len;
struct lttng_ust_ctl_reg_msg reg_msg;
reg_msg.uint64_t_alignment = uint64_t_alignment;
reg_msg.long_alignment = long_alignment;
reg_msg.socket_type = type;
- lttng_pthread_getname_np(reg_msg.name, LTTNG_UST_ABI_PROCNAME_LEN);
+ memset(reg_msg.name, 0, sizeof(reg_msg.name));
+ strncpy(reg_msg.name, procname, sizeof(reg_msg.name) - 1);
memset(reg_msg.padding, 0, sizeof(reg_msg.padding));
len = ustcomm_send_unix_sock(sock, ®_msg, sizeof(reg_msg));
strncpy(uf->name, field_name, LTTNG_UST_ABI_SYM_NAME_LEN);
uf->name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
- uf->type.atype = lttng_ust_ctl_atype_variant;
+ uf->type.atype = lttng_ust_ctl_atype_variant_nestable;
uf->type.u.variant_nestable.nr_choices = nr_choices;
strncpy(uf->type.u.variant_nestable.tag_name,
tag_field_name,
}
/*
- * Set socket reciving timeout.
+ * Set socket receiving timeout.
*/
int ustcomm_setsockopt_rcv_timeout(int sock, unsigned int msec)
{