149
151
// NOTE: This relies on the file descriptor cmsg being read
150
152
// (and written) atomically.
151
153
if (cmsg->cmsg_len > CMSG_LEN(fds_bytes) || (header.msg_flags & MSG_CTRUNC))
153
154
BOOST_THROW_EXCEPTION(std::runtime_error("Received more fds than expected"));
155
157
if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS)
159
159
int const* const data = reinterpret_cast<int const*>CMSG_DATA(cmsg);
160
160
ptrdiff_t const header_size = reinterpret_cast<char const*>(data) - reinterpret_cast<char const*>(cmsg);
161
161
int const nfds = (cmsg->cmsg_len - header_size) / sizeof(int);