unix,win: add uv_udp_try_send2#4644
Conversation
Shuffle around and DRY the sendmsg logic in preparation for uv_udp_try_send2(). NFC barring bugs. This work was sponsored by ISC, the Internet Systems Consortium.
Add a version of uv_udp_try_send that can send multiple datagrams. Uses sendmmsg(2) on platforms that support it (Linux, FreeBSD, macOS), falls back to a regular sendmsg(2) loop elsewhere. This work was sponsored by ISC, the Internet Systems Consortium.
I like |
|
Okay, |
| fallback loop for platforms that do not support the former. The handle must | ||
| be fully initialized; call c:func:`uv_udp_bind` first. |
There was a problem hiding this comment.
The handle must be fully initialized; call
uv_udp_bindfirst.
Could I get some clarification about this? uv_udp_bind is not called on the client handle in the updated test-udp-try-send.c.
EDIT: Nevermind, I see now that, in the test code, the earlier uv_udp_try_send call handles the bind.
|
Too late but what's the purpose of the int uv_udp_try_send2(uv_udp_t* handle,
unsigned int count,
uv_buf_t* bufs[/*count*/],
unsigned int nbufs[/*count*/],
struct sockaddr* addrs[/*count*/],
unsigned int flags) {
if (count < 1)
return UV_EINVAL;
if (flags != 0)
return UV_EINVAL;Basically if |
|
Usually we add those for future usage. |
Makes sense. Maybe some docs stating that flags must be 0 for now would be helpful to avoid confusion (people maybe tempted to use same flags as in other uv_udp related functions). |
|
Another thing I don't understand from the int uv_udp_try_send2(uv_udp_t* handle,
unsigned int count,
uv_buf_t* bufs[/*count*/],
unsigned int nbufs[/*count*/],
struct sockaddr* addrs[/*count*/],
unsigned int flags)So imagine I have a single uv_udp_try_send2(handle,
2 /*count*/,
[&buf, &buf] /*bufs[count]*/,
[1, 1] /*nbufs[count]*/,
[sockaddr1, sockaddr2] /*addrs[count]*/,
0 /*flags*/) |
Yep. If you check the implementation: Line 1302 in db3d0ff |
Yes. The thing is: what about if I just read the docs? |
|
But who does that? :-P |
I tried. Then I add to dig into the PR and the test it includes. |
Add a version of uv_udp_try_send that can send multiple datagrams.
Uses sendmmsg(2) on platforms that support it (Linux, FreeBSD, macOS),
falls back to a regular sendmsg(2) loop elsewhere.
This work was sponsored by ISC, the Internet Systems Consortium.
The first commit is a NFC that is prep work for the second commit. Same line count, more functionality, improved legibility (IMO)
I moved
uv__udp_sendmsgto the bottom of udp.c because the diff is crazy hard to read otherwise.I don't love the name
uv_udp_try_send2but I guess it's convention by now. Can I see hands foruv_udp_try_sendv?uv_udp_try_send_many? Other suggestions?