diff --git a/io/channel-socket.c b/io/channel-socket.c index de259f7eed..606ec97cf7 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -487,15 +487,15 @@ static ssize_t qio_channel_socket_readv(QIOChannel *ioc, memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)); -#ifdef MSG_CMSG_CLOEXEC - sflags |= MSG_CMSG_CLOEXEC; -#endif - msg.msg_iov = (struct iovec *)iov; msg.msg_iovlen = niov; if (fds && nfds) { msg.msg_control = control; msg.msg_controllen = sizeof(control); +#ifdef MSG_CMSG_CLOEXEC + sflags |= MSG_CMSG_CLOEXEC; +#endif + } retry: