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 <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
lundibundi authored and BethGriggs committed Feb 6, 2020
1 parent 54c60d2 commit da9fffa
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/node_http2.cc
Expand Up @@ -1907,14 +1907,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 da9fffa

Please sign in to comment.