Skip to content

Commit

Permalink
http2: small clean up in OnStreamRead
Browse files Browse the repository at this point in the history
PR-URL: #30351
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
lundibundi authored and targos committed Dec 9, 2019
1 parent 43e947a commit 3840abe
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1867,14 +1867,10 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) {
// call in OnStreamAfterWrite() immediately provides data. If that does
// happen, we concatenate the data we received with the already-stored
// pending input data, slicing off the already processed part.
AllocatedBuffer new_buf = env()->AllocateManaged(
stream_buf_.len - stream_buf_offset_ + nread);
memcpy(new_buf.data(),
stream_buf_.base + stream_buf_offset_,
stream_buf_.len - stream_buf_offset_);
memcpy(new_buf.data() + stream_buf_.len - stream_buf_offset_,
buf.data(),
nread);
size_t pending_len = stream_buf_.len - stream_buf_offset_;
AllocatedBuffer new_buf = env()->AllocateManaged(pending_len + nread);
memcpy(new_buf.data(), stream_buf_.base + stream_buf_offset_, pending_len);
memcpy(new_buf.data() + pending_len, buf.data(), nread);
buf = std::move(new_buf);
nread = buf.size();
stream_buf_offset_ = 0;
Expand Down

0 comments on commit 3840abe

Please sign in to comment.