Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-03-24 19:21:14 +0300
committerAnna Henningsen <anna@addaleax.net>2018-03-30 15:20:52 +0300
commitb7cfd278a53d2b7769340ed800142f6662aa48d2 (patch)
tree4f25fde46efd0f51a7fd2cf73cb4d0338b991c10 /src/stream_base-inl.h
parent1dc8eb4bd34383830d48a704d79a2bc9ec55152f (diff)
src: clean up `req.bytes` tracking
Simply always tell the caller how many bytes were written, rather than letting them track it. In the case of writing a string, also keep track of the bytes written by the earlier `DoTryWrite()`. Refs: https://github.com/nodejs/node/issues/19562 PR-URL: https://github.com/nodejs/node/pull/19551 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/stream_base-inl.h')
-rw-r--r--src/stream_base-inl.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h
index 35e49dfea2c..392dc2c87c3 100644
--- a/src/stream_base-inl.h
+++ b/src/stream_base-inl.h
@@ -194,13 +194,15 @@ inline StreamWriteResult StreamBase::Write(
Environment* env = stream_env();
int err;
+ size_t total_bytes = 0;
for (size_t i = 0; i < count; ++i)
- bytes_written_ += bufs[i].len;
+ total_bytes += bufs[i].len;
+ bytes_written_ += total_bytes;
if (send_handle == nullptr) {
err = DoTryWrite(&bufs, &count);
if (err != 0 || count == 0) {
- return StreamWriteResult { false, err, nullptr };
+ return StreamWriteResult { false, err, nullptr, total_bytes };
}
}
@@ -230,7 +232,7 @@ inline StreamWriteResult StreamBase::Write(
ClearError();
}
- return StreamWriteResult { async, err, req_wrap };
+ return StreamWriteResult { async, err, req_wrap, total_bytes };
}
template <typename OtherBase>