X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fconsumer.c;h=f57cfffff57262cbb04ef048fb761e75019eb805;hp=70cde9c1028d978d7deb1865ff84fe9455988a56;hb=f50f23d9f80ed9fae7fe5c49aee65e813e0031c8;hpb=7c5aef6226a4752f3a4e60cd0b52c741dced395e diff --git a/src/common/consumer.c b/src/common/consumer.c index 70cde9c10..f57cfffff 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -2679,10 +2679,18 @@ int consumer_add_relayd_socket(int net_seq_idx, int sock_type, struct pollfd *consumer_sockpoll, struct lttcomm_sock *relayd_sock) { int fd = -1, ret = -1; + enum lttng_error_code ret_code = LTTNG_OK; struct consumer_relayd_sock_pair *relayd; DBG("Consumer adding relayd socket (idx: %d)", net_seq_idx); + /* First send a status message before receiving the fds. */ + ret = consumer_send_status_msg(sock, ret_code); + if (ret < 0) { + /* Somehow, the session daemon is not responding anymore. */ + goto error; + } + /* Get relayd reference if exists. */ relayd = consumer_find_relayd(net_seq_idx); if (relayd == NULL) { @@ -2709,6 +2717,13 @@ int consumer_add_relayd_socket(int net_seq_idx, int sock_type, goto error; } + /* We have the fds without error. Send status back. */ + ret = consumer_send_status_msg(sock, ret_code); + if (ret < 0) { + /* Somehow, the session daemon is not responding anymore. */ + goto error; + } + /* Copy socket information and received FD */ switch (sock_type) { case LTTNG_STREAM_CONTROL: @@ -2913,3 +2928,17 @@ data_not_pending: rcu_read_unlock(); return 1; } + +/* + * Send a ret code status message to the sessiond daemon. + * + * Return the sendmsg() return value. + */ +int consumer_send_status_msg(int sock, int ret_code) +{ + struct lttcomm_consumer_status_msg msg; + + msg.ret_code = ret_code; + + return lttcomm_send_unix_sock(sock, &msg, sizeof(msg)); +}