Fix use of unportable MSG_CMSG_CLOEXEC

This commit is contained in:
Maxime Coste 2020-05-17 21:27:56 +10:00
parent b44c4f41a6
commit 5fd548d5cf

View File

@ -294,7 +294,7 @@ private:
msg.msg_control = fdbuf;
msg.msg_controllen = sizeof(fdbuf);
int res = recvmsg(sock, &msg, MSG_CMSG_CLOEXEC);
int res = recvmsg(sock, &msg, 0);
if (res <= 0)
throw disconnected{format("socket read failed: {}", strerror(errno))};
@ -305,6 +305,7 @@ private:
{
m_ancillary_fd.map(close);
memcpy(&m_ancillary_fd.emplace(), CMSG_DATA(cmsg), sizeof(int));
fcntl(*m_ancillary_fd, F_SETFD, FD_CLOEXEC);
}
}