Skip to content

Commit

Permalink
channel-socket: Only set CLOEXEC if we have space for fds
Browse files Browse the repository at this point in the history
MSG_CMSG_CLOEXEC cleans up received fd's; it's really only for Unix
sockets, but currently we enable it for everything; some socket types
(IP_MPTCP) don't like this.

Only enable it when we're giving the recvmsg room to receive fd's
anyway.

Signed-off-by: Dr. David Alan Gilbert <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Dr. David Alan Gilbert <[email protected]>
  • Loading branch information
dagrh committed Jun 8, 2021
1 parent 6b8c2eb commit d80f54c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions io/channel-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d80f54c

Please sign in to comment.