udp: Fix mmsghdr struct initializer for Musl

On OpenWrt x64 there are paddings fields in the struct, making
the initializer list not work.
This commit is contained in:
klzgrad 2020-02-06 03:07:46 +08:00
parent 32e61b4cb2
commit 766f4c0280

View File

@ -1156,8 +1156,12 @@ SendResult UDPSocketPosixSender::InternalSendmmsgBuffers(
for (auto& buffer : buffers) for (auto& buffer : buffers)
msg_iov->push_back({const_cast<char*>(buffer->data()), buffer->length()}); msg_iov->push_back({const_cast<char*>(buffer->data()), buffer->length()});
msgvec->reserve(buffers.size()); msgvec->reserve(buffers.size());
for (size_t j = 0; j < buffers.size(); j++) for (size_t j = 0; j < buffers.size(); j++) {
msgvec->push_back({{nullptr, 0, &msg_iov[j], 1, nullptr, 0, 0}, 0}); 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)); int result = HANDLE_EINTR(Sendmmsg(fd, &msgvec[0], buffers.size(), 0));
SendResult send_result(0, 0, std::move(buffers)); SendResult send_result(0, 0, std::move(buffers));
if (result < 0) { if (result < 0) {