assert(sock);
- ret = lttcomm_recv_unix_sock(sock->fd, &reply, sizeof(reply));
+ ret = lttcomm_recv_unix_sock(*sock->fd, &reply, sizeof(reply));
if (ret <= 0) {
if (ret == 0) {
/* Orderly shutdown. Don't return 0 which means success. */
ret = -1;
}
/* The above call will print a PERROR on error. */
- DBG("Fail to receive status reply on sock %d", sock->fd);
+ DBG("Fail to receive status reply on sock %d", *sock->fd);
goto end;
}
assert(stream_count);
assert(key);
- ret = lttcomm_recv_unix_sock(sock->fd, &reply, sizeof(reply));
+ ret = lttcomm_recv_unix_sock(*sock->fd, &reply, sizeof(reply));
if (ret <= 0) {
if (ret == 0) {
/* Orderly shutdown. Don't return 0 which means success. */
ret = -1;
}
/* The above call will print a PERROR on error. */
- DBG("Fail to receive status reply on sock %d", sock->fd);
+ DBG("Fail to receive status reply on sock %d", *sock->fd);
goto end;
}
assert(consumer);
assert(sock);
- DBG2("Sending destroy relayd command to consumer sock %d", sock->fd);
+ DBG2("Sending destroy relayd command to consumer sock %d", *sock->fd);
/* Bail out if consumer is disabled */
if (!consumer->enabled) {
msg.u.destroy_relayd.net_seq_idx = consumer->net_seq_index;
pthread_mutex_lock(sock->lock);
- ret = lttcomm_send_unix_sock(sock->fd, &msg, sizeof(msg));
+ ret = lttcomm_send_unix_sock(*sock->fd, &msg, sizeof(msg));
if (ret < 0) {
/* Indicate that the consumer is probably closing at this point. */
DBG("send consumer destroy relayd command");
socket = consumer_find_socket(data->cmd_sock, output);
rcu_read_unlock();
if (socket == NULL) {
- socket = consumer_allocate_socket(data->cmd_sock);
+ socket = consumer_allocate_socket(&data->cmd_sock);
if (socket == NULL) {
ret = -1;
goto error;
/*
* Allocate a new consumer_socket and return the pointer.
*/
-struct consumer_socket *consumer_allocate_socket(int fd)
+struct consumer_socket *consumer_allocate_socket(int *fd)
{
struct consumer_socket *socket = NULL;
+ assert(fd);
+
socket = zmalloc(sizeof(struct consumer_socket));
if (socket == NULL) {
PERROR("zmalloc consumer socket");
}
socket->fd = fd;
- lttng_ht_node_init_ulong(&socket->node, fd);
+ lttng_ht_node_init_ulong(&socket->node, *fd);
error:
return socket;
* consumer was registered,
*/
if (sock->registered) {
- DBG3("Consumer socket was registered. Closing fd %d", sock->fd);
- lttcomm_close_unix_sock(sock->fd);
+ DBG3("Consumer socket was registered. Closing fd %d", *sock->fd);
+ lttcomm_close_unix_sock(*sock->fd);
}
call_rcu(&sock->node.head, destroy_socket_rcu);
rcu_read_lock();
cds_lfht_for_each_entry(src->socks->ht, &iter.iter, socket, node.node) {
/* Ignore socket that are already there. */
- copy_sock = consumer_find_socket(socket->fd, dst);
+ copy_sock = consumer_find_socket(*socket->fd, dst);
if (copy_sock) {
continue;
}
assert(fds);
assert(sock);
+ assert(sock->fd);
assert(nb_fd > 0);
- ret = lttcomm_send_fds_unix_sock(sock->fd, fds, nb_fd);
+ ret = lttcomm_send_fds_unix_sock(*sock->fd, fds, nb_fd);
if (ret < 0) {
/* The above call will print a PERROR on error. */
- DBG("Error when sending consumer fds on sock %d", sock->fd);
+ DBG("Error when sending consumer fds on sock %d", *sock->fd);
goto error;
}
assert(msg);
assert(sock);
- assert(sock->fd >= 0);
+ assert(sock->fd);
- ret = lttcomm_send_unix_sock(sock->fd, msg,
+ ret = lttcomm_send_unix_sock(*sock->fd, msg,
sizeof(struct lttcomm_consumer_msg));
if (ret < 0) {
/* The above call will print a PERROR on error. */
- DBG("Error when sending consumer channel on sock %d", sock->fd);
+ DBG("Error when sending consumer channel on sock %d", *sock->fd);
goto error;
}
assert(msg);
assert(sock);
- assert(sock->fd >= 0);
+ assert(sock->fd);
- ret = lttcomm_send_unix_sock(sock->fd, msg,
+ ret = lttcomm_send_unix_sock(*sock->fd, msg,
sizeof(struct lttcomm_consumer_msg));
if (ret < 0) {
/* The above call will print a PERROR on error. */
- DBG("Error when sending consumer channel on sock %d", sock->fd);
+ DBG("Error when sending consumer channel on sock %d", *sock->fd);
goto error;
}
assert(msg);
assert(dst);
assert(sock);
+ assert(sock->fd);
assert(fds);
/* Send on socket */
- ret = lttcomm_send_unix_sock(sock->fd, msg,
+ ret = lttcomm_send_unix_sock(*sock->fd, msg,
sizeof(struct lttcomm_consumer_msg));
if (ret < 0) {
/* The above call will print a PERROR on error. */
- DBG("Error when sending consumer stream on sock %d", sock->fd);
+ DBG("Error when sending consumer stream on sock %d", *sock->fd);
goto error;
}
assert(rsock);
assert(consumer);
assert(consumer_sock);
+ assert(consumer_sock->fd);
/* Bail out if consumer is disabled */
if (!consumer->enabled) {
msg.u.relayd_sock.session_id = session_id;
memcpy(&msg.u.relayd_sock.sock, rsock, sizeof(msg.u.relayd_sock.sock));
- DBG3("Sending relayd sock info to consumer on %d", consumer_sock->fd);
- ret = lttcomm_send_unix_sock(consumer_sock->fd, &msg, sizeof(msg));
+ DBG3("Sending relayd sock info to consumer on %d", *consumer_sock->fd);
+ ret = lttcomm_send_unix_sock(*consumer_sock->fd, &msg, sizeof(msg));
if (ret < 0) {
/* The above call will print a PERROR on error. */
DBG("Error when sending relayd sockets on sock %d", rsock->sock.fd);
cds_lfht_for_each_entry(consumer->socks->ht, &iter.iter, socket,
node.node) {
/* Code flow error */
- assert(socket->fd >= 0);
+ assert(socket->fd);
pthread_mutex_lock(socket->lock);
- ret = lttcomm_send_unix_sock(socket->fd, &msg, sizeof(msg));
+ ret = lttcomm_send_unix_sock(*socket->fd, &msg, sizeof(msg));
if (ret < 0) {
/* The above call will print a PERROR on error. */
- DBG("Error on consumer is data pending on sock %d", socket->fd);
+ DBG("Error on consumer is data pending on sock %d", *socket->fd);
pthread_mutex_unlock(socket->lock);
goto error_unlock;
}
* the reply status message.
*/
- ret = lttcomm_recv_unix_sock(socket->fd, &ret_code, sizeof(ret_code));
+ ret = lttcomm_recv_unix_sock(*socket->fd, &ret_code, sizeof(ret_code));
if (ret <= 0) {
if (ret == 0) {
/* Orderly shutdown. Don't return 0 which means success. */
ret = -1;
}
/* The above call will print a PERROR on error. */
- DBG("Error on recv consumer is data pending on sock %d", socket->fd);
+ DBG("Error on recv consumer is data pending on sock %d", *socket->fd);
pthread_mutex_unlock(socket->lock);
goto error_unlock;
}
struct lttcomm_consumer_msg msg;
assert(socket);
- assert(socket->fd >= 0);
+ assert(socket->fd);
DBG2("Consumer flush channel key %" PRIu64, key);
struct lttcomm_consumer_msg msg;
assert(socket);
- assert(socket->fd >= 0);
+ assert(socket->fd);
DBG2("Consumer close metadata channel key %" PRIu64, metadata_key);
struct lttcomm_consumer_msg msg;
assert(socket);
- assert(socket->fd >= 0);
+ assert(socket->fd);
DBG2("Consumer setup metadata channel key %" PRIu64, metadata_key);
struct lttcomm_consumer_msg msg;
assert(socket);
- assert(socket->fd >= 0);
+ assert(socket->fd);
- DBG2("Consumer push metadata to consumer socket %d", socket->fd);
+ DBG2("Consumer push metadata to consumer socket %d", *socket->fd);
msg.cmd_type = LTTNG_CONSUMER_PUSH_METADATA;
msg.u.push_metadata.key = metadata_key;
goto end;
}
- DBG3("Consumer pushing metadata on sock %d of len %zu", socket->fd, len);
+ DBG3("Consumer pushing metadata on sock %d of len %zu", *socket->fd, len);
- ret = lttcomm_send_unix_sock(socket->fd, metadata_str, len);
+ ret = lttcomm_send_unix_sock(*socket->fd, metadata_str, len);
if (ret < 0) {
goto end;
}
struct lttcomm_consumer_msg msg;
assert(socket);
- assert(socket->fd >= 0);
+ assert(socket->fd);
assert(output);
assert(output->consumer);
.cmd_unix_sock_path = DEFAULT_KCONSUMERD_CMD_SOCK_PATH,
.err_sock = -1,
.cmd_sock = -1,
- .metadata_sock.fd = -1,
.pid_mutex = PTHREAD_MUTEX_INITIALIZER,
.lock = PTHREAD_MUTEX_INITIALIZER,
.cond = PTHREAD_COND_INITIALIZER,
.cmd_unix_sock_path = DEFAULT_USTCONSUMERD64_CMD_SOCK_PATH,
.err_sock = -1,
.cmd_sock = -1,
- .metadata_sock.fd = -1,
.pid_mutex = PTHREAD_MUTEX_INITIALIZER,
.lock = PTHREAD_MUTEX_INITIALIZER,
.cond = PTHREAD_COND_INITIALIZER,
.cmd_unix_sock_path = DEFAULT_USTCONSUMERD32_CMD_SOCK_PATH,
.err_sock = -1,
.cmd_sock = -1,
- .metadata_sock.fd = -1,
.pid_mutex = PTHREAD_MUTEX_INITIALIZER,
.lock = PTHREAD_MUTEX_INITIALIZER,
.cond = PTHREAD_COND_INITIALIZER,
cds_lfht_for_each_entry(ksess->consumer->socks->ht,
&iter.iter, socket, node.node) {
/* Code flow error */
- assert(socket->fd >= 0);
+ assert(socket->fd);
pthread_mutex_lock(socket->lock);
ret = kernel_consumer_send_channel_stream(socket,
/* Connect both socket, command and metadata. */
consumer_data->cmd_sock =
lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path);
- consumer_data->metadata_sock.fd =
+ consumer_data->metadata_fd =
lttcomm_connect_unix_sock(consumer_data->cmd_unix_sock_path);
- if (consumer_data->cmd_sock < 0 ||
- consumer_data->metadata_sock.fd < 0) {
+ if (consumer_data->cmd_sock < 0 || consumer_data->metadata_fd < 0) {
PERROR("consumer connect cmd socket");
/* On error, signal condition and quit. */
signal_consumer_condition(consumer_data, -1);
goto error;
}
+ consumer_data->metadata_sock.fd = &consumer_data->metadata_fd;
/* Create metadata socket lock. */
consumer_data->metadata_sock.lock = zmalloc(sizeof(pthread_mutex_t));
if (consumer_data->metadata_sock.lock == NULL) {
signal_consumer_condition(consumer_data, 1);
DBG("Consumer command socket ready (fd: %d", consumer_data->cmd_sock);
DBG("Consumer metadata socket ready (fd: %d)",
- consumer_data->metadata_sock.fd);
+ consumer_data->metadata_fd);
} else {
ERR("consumer error when waiting for SOCK_READY : %s",
lttcomm_get_readable_code(-code));
}
/* Add metadata socket that is successfully connected. */
- ret = lttng_poll_add(&events, consumer_data->metadata_sock.fd,
+ ret = lttng_poll_add(&events, consumer_data->metadata_fd,
LPOLLIN | LPOLLRDHUP);
if (ret < 0) {
goto error;
lttcomm_get_readable_code(-code));
goto exit;
- } else if (pollfd == consumer_data->metadata_sock.fd) {
+ } else if (pollfd == consumer_data->metadata_fd) {
/* UST metadata requests */
ret = ust_consumer_metadata_request(
&consumer_data->metadata_sock);
}
consumer_data->cmd_sock = -1;
}
- if (consumer_data->metadata_sock.fd >= 0) {
- ret = close(consumer_data->metadata_sock.fd);
+ if (*consumer_data->metadata_sock.fd >= 0) {
+ ret = close(*consumer_data->metadata_sock.fd);
if (ret) {
PERROR("close");
}
health_code_update();
- ret = lttcomm_send_unix_sock(socket->fd, &msg, sizeof(msg));
+ ret = lttcomm_send_unix_sock(*socket->fd, &msg, sizeof(msg));
if (ret < 0) {
goto error;
}
assert(ua_chan);
assert(consumer);
assert(socket);
- assert(socket->fd >= 0);
+ assert(socket->fd);
assert(registry);
if (!consumer->enabled) {
assert(ua_chan);
assert(socket);
- assert(socket->fd >= 0);
+ assert(socket->fd);
msg.cmd_type = LTTNG_CONSUMER_GET_CHANNEL;
msg.u.get_channel.key = ua_chan->key;
}
/* First, get the channel from consumer. */
- ret = ustctl_recv_channel_from_consumer(socket->fd, &ua_chan->obj);
+ ret = ustctl_recv_channel_from_consumer(*socket->fd, &ua_chan->obj);
if (ret < 0) {
if (ret != -EPIPE) {
ERR("Error recv channel from consumer %d with ret %d",
- socket->fd, ret);
+ *socket->fd, ret);
} else {
DBG3("UST app recv channel from consumer. Consumer is dead.");
}
}
/* Stream object is populated by this call if successful. */
- ret = ustctl_recv_stream_from_consumer(socket->fd, &stream->obj);
+ ret = ustctl_recv_stream_from_consumer(*socket->fd, &stream->obj);
if (ret < 0) {
free(stream);
if (ret == -LTTNG_UST_ERR_NOENT) {
}
if (ret != -EPIPE) {
ERR("Recv stream from consumer %d with ret %d",
- socket->fd, ret);
+ *socket->fd, ret);
} else {
DBG3("UST app recv stream from consumer. Consumer is dead.");
}
assert(ua_chan);
assert(socket);
- assert(socket->fd >= 0);
+ assert(socket->fd);
msg.cmd_type = LTTNG_CONSUMER_DESTROY_CHANNEL;
msg.u.destroy_channel.key = ua_chan->key;
health_code_update();
/* Wait for a metadata request */
- ret = lttcomm_recv_unix_sock(socket->fd, &request, sizeof(request));
+ ret = lttcomm_recv_unix_sock(*socket->fd, &request, sizeof(request));
if (ret <= 0) {
ERR("Consumer closed the metadata socket");
ret = -1;