Skip to content

Commit

Permalink
Make a writem API with just iovecs [5/n]
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Aman Sharma authored and facebook-github-bot committed Jan 29, 2025
1 parent 68f2308 commit 96fa1cd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions folly/io/async/AsyncUDPSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,14 @@ int AsyncUDPSocket::writemGSO(
return ret;
}

int AsyncUDPSocket::writemv(
Range<SocketAddress const*> addrs,
iovec* iov,
size_t* numIovecsInBuffer,
size_t count) {
return writemGSOv(addrs, iov, numIovecsInBuffer, count, nullptr);
}

int AsyncUDPSocket::writemGSOv(
Range<SocketAddress const*> addrs,
iovec* iov,
Expand Down
13 changes: 13 additions & 0 deletions folly/io/async/AsyncUDPSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,19 @@ class AsyncUDPSocket : public EventHandler {
const std::unique_ptr<folly::IOBuf>* 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<SocketAddress const*> addrs,
iovec* iov,
size_t* numIovecsInBuffer,
size_t count);

/**
* Send the data in buffer to destination. Returns the return code from
* ::sendmsg.
Expand Down

0 comments on commit 96fa1cd

Please sign in to comment.