Skip to content

Commit 47693e3

Browse files
andreazevedofacebook-github-bot
authored andcommitted
Add getTotalBufferedBytes() method fo AsyncTransport
Summary: When BufferCallback::onEgressBuffered() is called, applications usually want to know how many bytes were buffered so that can take actions (such as avoiding that connection, failing fast, etc). This diff adds getTotalPendingBytes() to AsyncTransport to allow applications to easily query how many bytes were actually buffered. Reviewed By: spalamarchuk Differential Revision: D13252677 fbshipit-source-id: 8ec203f6764e00f52d471321afb549376397eb84
1 parent b4c5c8e commit 47693e3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mcrouter/lib/carbon/CarbonQueueAppender.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ class CarbonQueueAppenderStorage {
5151
assert(nIovsUsed_ < kMaxIovecs);
5252

5353
struct iovec* nextIov = iovs_ + nIovsUsed_;
54-
const auto nFilled = buf.fillIov(nextIov, kMaxIovecs - nIovsUsed_);
54+
const auto nFilled =
55+
buf.fillIov(nextIov, kMaxIovecs - nIovsUsed_).numIovecs;
5556

5657
if (tcpZeroCopyThreshold_ && !applyZeroCopy_ &&
5758
buf.capacity() >= tcpZeroCopyThreshold_) {
@@ -109,7 +110,8 @@ class CarbonQueueAppenderStorage {
109110

110111
bool setFullBuffer(const folly::IOBuf& buf) {
111112
struct iovec* nextIov = iovs_ + nIovsUsed_;
112-
const auto nFilled = buf.fillIov(nextIov, kMaxIovecs - nIovsUsed_);
113+
const auto nFilled =
114+
buf.fillIov(nextIov, kMaxIovecs - nIovsUsed_).numIovecs;
113115

114116
if (nFilled > 0) {
115117
nIovsUsed_ += nFilled;
@@ -215,7 +217,8 @@ class CarbonQueueAppenderStorage {
215217
struct iovec* nextIov = iovs_ + nIovsUsed_;
216218
auto bufCopy = buf;
217219
bufCopy.coalesce();
218-
const auto nFilledRetry = bufCopy.fillIov(nextIov, kMaxIovecs - nIovsUsed_);
220+
const auto nFilledRetry =
221+
bufCopy.fillIov(nextIov, kMaxIovecs - nIovsUsed_).numIovecs;
219222
assert(nFilledRetry == 1);
220223
(void)nFilledRetry;
221224
++nIovsUsed_;

0 commit comments

Comments
 (0)