From: Mathieu Desnoyers Date: Thu, 27 Oct 2011 12:02:40 +0000 (-0400) Subject: Fix kconsumerd number of fd expected X-Git-Tag: v2.0-pre15~181 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f2fc6720dff91c4076318acff69aa3bb5e70060a;p=lttng-tools.git Fix kconsumerd number of fd expected Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng-sessiond-comm.h b/include/lttng-sessiond-comm.h index 68d8b9109..7da343a9d 100644 --- a/include/lttng-sessiond-comm.h +++ b/include/lttng-sessiond-comm.h @@ -119,6 +119,7 @@ enum lttcomm_return_code { CONSUMERD_COMMAND_SOCK_READY, /* when consumerd command socket ready */ CONSUMERD_SUCCESS_RECV_FD, /* success on receiving fds */ CONSUMERD_ERROR_RECV_FD, /* error on receiving fds */ + CONSUMERD_ERROR_RECV_CMD, /* error on receiving command */ CONSUMERD_POLL_ERROR, /* Error in polling thread in kconsumerd */ CONSUMERD_POLL_NVAL, /* Poll on closed fd */ CONSUMERD_POLL_HUP, /* All fds have hungup */ diff --git a/liblttng-kconsumer/lttng-kconsumer.c b/liblttng-kconsumer/lttng-kconsumer.c index 407451781..778dd1631 100644 --- a/liblttng-kconsumer/lttng-kconsumer.c +++ b/liblttng-kconsumer/lttng-kconsumer.c @@ -200,7 +200,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, ret = lttcomm_recv_unix_sock(sock, &msg, sizeof(msg)); if (ret != sizeof(msg)) { - lttng_consumer_send_error(ctx, CONSUMERD_ERROR_RECV_FD); + lttng_consumer_send_error(ctx, CONSUMERD_ERROR_RECV_CMD); return ret; } if (msg.cmd_type == LTTNG_CONSUMER_STOP) { @@ -236,26 +236,23 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, case LTTNG_CONSUMER_ADD_STREAM: { struct lttng_consumer_stream *new_stream; - int fds[2]; - size_t nb_fd = 1; + int fd; /* block */ if (lttng_consumer_poll_socket(consumer_sockpoll) < 0) { return -EINTR; } - ret = lttcomm_recv_fds_unix_sock(sock, fds, nb_fd); - if (ret != sizeof(fds)) { + ret = lttcomm_recv_fds_unix_sock(sock, &fd, 1); + if (ret != sizeof(fd)) { lttng_consumer_send_error(ctx, CONSUMERD_ERROR_RECV_FD); return ret; } - if (nb_fd < 2) - fds[1] = fds[0]; /* duplicate same fd if recv only one */ - DBG("consumer_add_stream %s (%d,%d)", msg.u.stream.path_name, - fds[0], fds[1]); + DBG("consumer_add_stream %s (%d)", msg.u.stream.path_name, + fd); new_stream = consumer_allocate_stream(msg.u.stream.channel_key, msg.u.stream.stream_key, - fds[0], fds[1], + fd, fd, msg.u.stream.state, msg.u.stream.mmap_len, msg.u.stream.output, diff --git a/liblttng-sessiond-comm/lttng-sessiond-comm.c b/liblttng-sessiond-comm/lttng-sessiond-comm.c index 5ba609e5a..6e0e83b79 100644 --- a/liblttng-sessiond-comm/lttng-sessiond-comm.c +++ b/liblttng-sessiond-comm/lttng-sessiond-comm.c @@ -79,6 +79,7 @@ static const char *lttcomm_readable_code[] = { [ LTTCOMM_ERR_INDEX(CONSUMERD_COMMAND_SOCK_READY) ] = "consumerd command socket ready", [ LTTCOMM_ERR_INDEX(CONSUMERD_SUCCESS_RECV_FD) ] = "consumerd success on receiving fds", [ LTTCOMM_ERR_INDEX(CONSUMERD_ERROR_RECV_FD) ] = "consumerd error on receiving fds", + [ LTTCOMM_ERR_INDEX(CONSUMERD_ERROR_RECV_CMD) ] = "consumerd error on receiving command", [ LTTCOMM_ERR_INDEX(CONSUMERD_POLL_ERROR) ] = "consumerd error in polling thread", [ LTTCOMM_ERR_INDEX(CONSUMERD_POLL_NVAL) ] = "consumerd polling on closed fd", [ LTTCOMM_ERR_INDEX(CONSUMERD_POLL_HUP) ] = "consumerd all fd hung up",