Prepare mmsghdr structure properly. (#2346)
Motivation: According to the Linux man page the msg_len field supposed to be used to return a number of bytes sent for the particular message. It does not make a sense to initialize it with a size of the message. Modifications: Change msg_leg field initialization, use 0 instead of message size. Result: Use sendmmsg() call properly. Co-authored-by: Cory Benfield <lukasa@apple.com>
This commit is contained in:
parent
602989b003
commit
c8ec84ef3b
|
@ -139,7 +139,7 @@ private func doPendingDatagramWriteVectorOperation(pending: PendingDatagramWrite
|
|||
msg_control: controlMessageBytePointer.baseAddress,
|
||||
msg_controllen: .init(controlMessageBytePointer.count),
|
||||
msg_flags: 0)
|
||||
msgs[c] = MMsgHdr(msg_hdr: msg, msg_len: CUnsignedInt(toWriteForThisBuffer))
|
||||
msgs[c] = MMsgHdr(msg_hdr: msg, msg_len: 0)
|
||||
}
|
||||
c += 1
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ class PendingDatagramWritesManagerTests: XCTestCase {
|
|||
XCTAssertEqual(expected[multiState].map { numericCast($0.0) }, ptrs.map { $0.msg_hdr.msg_iov.pointee.iov_len },
|
||||
"in vector write \(multiState) (overall \(everythingState)), \(expected[multiState]) byte counts expected but \(ptrs.map { $0.msg_hdr.msg_iov.pointee.iov_len }) actual",
|
||||
file: (file), line: line)
|
||||
XCTAssertEqual(expected[multiState].map { $0.0 }, ptrs.map { Int($0.msg_len) },
|
||||
XCTAssertEqual(ptrs.map { Int($0.msg_len) }, Array(repeating: 0, count: ptrs.count),
|
||||
"in vector write \(multiState) (overall \(everythingState)), \(expected[multiState]) byte counts expected but \(ptrs.map { $0.msg_len }) actual",
|
||||
file: (file), line: line)
|
||||
XCTAssertEqual(expected[multiState].map { $0.1 }, ptrs.map { SocketAddress($0.msg_hdr.msg_name.assumingMemoryBound(to: sockaddr.self)) }, "in vector write \(multiState) (overall \(everythingState)), \(expected[multiState].map { $0.1 }) addresses expected but \(ptrs.map { SocketAddress($0.msg_hdr.msg_name.assumingMemoryBound(to: sockaddr.self)) }) actual",
|
||||
|
|
Loading…
Reference in New Issue