Skip to content

Commit

Permalink
udp: Fix mmsghdr struct initializer for Musl
Browse files Browse the repository at this point in the history
On OpenWrt x64 there are paddings fields in the struct, making
the initializer list not work.
  • Loading branch information
klzgrad committed Nov 15, 2021
1 parent 72769b7 commit 99cc4bf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/net/socket/udp_socket_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1160,8 +1160,12 @@ SendResult UDPSocketPosixSender::InternalSendmmsgBuffers(
for (auto& buffer : buffers)
msg_iov->push_back({const_cast<char*>(buffer->data()), buffer->length()});
msgvec->reserve(buffers.size());
for (size_t j = 0; j < buffers.size(); j++)
msgvec->push_back({{nullptr, 0, &msg_iov[j], 1, nullptr, 0, 0}, 0});
for (size_t j = 0; j < buffers.size(); j++) {
struct mmsghdr hdr = {};
hdr.msg_hdr.msg_iov = &msg_iov[j];
hdr.msg_hdr.msg_iovlen = 1;
msgvec->push_back(hdr);
}
int result = HANDLE_EINTR(Sendmmsg(fd, &msgvec[0], buffers.size(), 0));
SendResult send_result(0, 0, std::move(buffers));
if (result < 0) {
Expand Down

0 comments on commit 99cc4bf

Please sign in to comment.