From 96fa1cd4a8f17e48fa0ee7bd1a0ec851d6945e6f Mon Sep 17 00:00:00 2001 From: Aman Sharma Date: Wed, 29 Jan 2025 13:10:57 -0800 Subject: [PATCH] Make a writem API with just iovecs [5/n] Summary: **Background for the diff stack**: We'd like to excise the usage of folly from a library that we maintain (quic), which is why we'd like to have a version of `writemGSO` that takes in iovecs instead of IOBufs. **What this diff is doing**: We're creating a new `writemv` function that does basically the same thing that `writem` does, except it uses `iovec`s instead of `IOBuf`s. This is pretty similar to `writem`. Reviewed By: mjoras Differential Revision: D68736205 fbshipit-source-id: b6dc9b1740d31bff97ec9e0b49923717f0b819b5 --- folly/io/async/AsyncUDPSocket.cpp | 8 ++++++++ folly/io/async/AsyncUDPSocket.h | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/folly/io/async/AsyncUDPSocket.cpp b/folly/io/async/AsyncUDPSocket.cpp index ea06074adfd..1ae5a8968b5 100644 --- a/folly/io/async/AsyncUDPSocket.cpp +++ b/folly/io/async/AsyncUDPSocket.cpp @@ -865,6 +865,14 @@ int AsyncUDPSocket::writemGSO( return ret; } +int AsyncUDPSocket::writemv( + Range addrs, + iovec* iov, + size_t* numIovecsInBuffer, + size_t count) { + return writemGSOv(addrs, iov, numIovecsInBuffer, count, nullptr); +} + int AsyncUDPSocket::writemGSOv( Range addrs, iovec* iov, diff --git a/folly/io/async/AsyncUDPSocket.h b/folly/io/async/AsyncUDPSocket.h index cc5e34daf96..e6910490a86 100644 --- a/folly/io/async/AsyncUDPSocket.h +++ b/folly/io/async/AsyncUDPSocket.h @@ -270,6 +270,19 @@ class AsyncUDPSocket : public EventHandler { const std::unique_ptr* bufs, size_t count); + /** + * Send the data in buffers to destination. Returns the return code from + * ::sendmmsg. + * iov is an array of iovecs, which is composed of "count" messages that + * need to be sent. Each message can have multiple iovecs. The number of + * iovecs per message is specified in numIovecsInBuffer. + */ + virtual int writemv( + Range addrs, + iovec* iov, + size_t* numIovecsInBuffer, + size_t count); + /** * Send the data in buffer to destination. Returns the return code from * ::sendmsg.