Skip to content

Commit

Permalink
Add getTotalBufferedBytes() method fo AsyncTransport
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andreazevedo authored and facebook-github-bot committed Dec 11, 2018
1 parent b4c5c8e commit 47693e3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mcrouter/lib/carbon/CarbonQueueAppender.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class CarbonQueueAppenderStorage {
assert(nIovsUsed_ < kMaxIovecs);

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

if (tcpZeroCopyThreshold_ && !applyZeroCopy_ &&
buf.capacity() >= tcpZeroCopyThreshold_) {
Expand Down Expand Up @@ -109,7 +110,8 @@ class CarbonQueueAppenderStorage {

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

if (nFilled > 0) {
nIovsUsed_ += nFilled;
Expand Down Expand Up @@ -215,7 +217,8 @@ class CarbonQueueAppenderStorage {
struct iovec* nextIov = iovs_ + nIovsUsed_;
auto bufCopy = buf;
bufCopy.coalesce();
const auto nFilledRetry = bufCopy.fillIov(nextIov, kMaxIovecs - nIovsUsed_);
const auto nFilledRetry =
bufCopy.fillIov(nextIov, kMaxIovecs - nIovsUsed_).numIovecs;
assert(nFilledRetry == 1);
(void)nFilledRetry;
++nIovsUsed_;
Expand Down

0 comments on commit 47693e3

Please sign in to comment.