Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 148de5b

Browse files
jianjunztaste1981
andauthored
Read data until readable bytes is 0. (#784)
* Read data until readable bytes is 0. * Check buffer allocated. Co-authored-by: taste1981 <[email protected]>
1 parent 37e6b80 commit 148de5b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

source/agent/addons/quic/QuicTransportStream.cc

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,20 @@ void QuicTransportStream::SignalOnData()
200200
return;
201201
}
202202

203-
auto readableBytes = m_stream->ReadableBytes();
204-
uint8_t* buffer = new uint8_t[readableBytes];
205-
owt_base::Frame frame;
206-
frame.format = owt_base::FRAME_FORMAT_DATA;
207-
frame.length = readableBytes;
208-
frame.payload = buffer;
209-
m_stream->Read(frame.payload, readableBytes);
210-
deliverFrame(frame);
203+
while (m_stream->ReadableBytes() > 0) {
204+
auto readableBytes = m_stream->ReadableBytes();
205+
uint8_t* buffer = new uint8_t[readableBytes];
206+
if (buffer == nullptr) {
207+
ELOG_ERROR("Failed to alloc buffer.");
208+
return;
209+
}
210+
owt_base::Frame frame;
211+
frame.format = owt_base::FRAME_FORMAT_DATA;
212+
frame.length = readableBytes;
213+
frame.payload = buffer;
214+
m_stream->Read(frame.payload, readableBytes);
215+
deliverFrame(frame);
216+
}
211217
}
212218

213219
void QuicTransportStream::onFeedback(const owt_base::FeedbackMsg&)

0 commit comments

Comments
 (0)