aboutsummaryrefslogtreecommitdiff
path: root/docs/src
diff options
context:
space:
mode:
authorSaúl Ibarra Corretgé <s@saghul.net>2020-03-12 20:27:35 +0100
committerSaúl Ibarra Corretgé <s@saghul.net>2020-03-24 08:27:00 +0100
commitd9cd7d437d6bcea56355b6e0ef215aa64687d7a1 (patch)
tree0feb1889e98936dc94e904b920d56d3b7cea3cb2 /docs/src
parent055e89f637fcd767096a3b258243c08fc5c93ddf (diff)
downloadlibuv-d9cd7d437d6bcea56355b6e0ef215aa64687d7a1.tar.gz
libuv-d9cd7d437d6bcea56355b6e0ef215aa64687d7a1.zip
udp: return recvmmsg-ed datagrams in order
When recvmmsg support was added it returned the datagrams in reverse received order, which may impact some applications. To restore the previous behavior, we call recv_cb one last time with nread == 0 and addr == NULL so applications can free the buffer. PR-URL: https://github.com/libuv/libuv/pull/2736 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'docs/src')
-rw-r--r--docs/src/udp.rst17
1 files changed, 12 insertions, 5 deletions
diff --git a/docs/src/udp.rst b/docs/src/udp.rst
index 2ca0736b..786a28b0 100644
--- a/docs/src/udp.rst
+++ b/docs/src/udp.rst
@@ -43,8 +43,7 @@ Data types
*/
UV_UDP_REUSEADDR = 4
/*
- * Indicates that the message was received by recvmmsg and that it's not at
- * the beginning of the buffer allocated by alloc_cb - so the buffer provided
+ * Indicates that the message was received by recvmmsg, so the buffer provided
* must not be freed by the recv_cb callback.
*/
UV_UDP_MMSG_CHUNK = 8
@@ -72,9 +71,13 @@ Data types
The callee is responsible for freeing the buffer, libuv does not reuse it.
The buffer may be a null buffer (where `buf->base` == NULL and `buf->len` == 0)
- on error. Don't free the buffer when the UV_UDP_MMSG_CHUNK flag is set.
- The final callback receives the whole buffer (containing the first chunk)
- with the UV_UDP_MMSG_CHUNK flag cleared.
+ on error.
+
+ When using :man:`recvmmsg(2)`, chunks will have the `UV_UDP_MMSG_CHUNK` flag set,
+ those must not be freed. There will be a final callback with `nread` set to 0,
+ `addr` set to NULL and the buffer pointing at the initially allocated data with
+ the `UV_UDP_MMSG_CHUNK` flag cleared. This is a good chance for the callee to
+ free the provided buffer.
.. note::
The receive callback will be called with `nread` == 0 and `addr` == NULL when there is
@@ -373,6 +376,10 @@ API
:returns: 0 on success, or an error code < 0 on failure.
+ .. versionchanged:: 1.35.0 added support for :man:`recvmmsg(2)` on supported platforms).
+ The use of this feature requires a buffer larger than
+ 2 * 64KB to be passed to `alloc_cb`.
+
.. c:function:: int uv_udp_recv_stop(uv_udp_t* handle)
Stop listening for incoming datagrams.