bneradt commented on code in PR #13186:
URL: https://github.com/apache/trafficserver/pull/13186#discussion_r3319995326


##########
src/proxy/http3/Http3StreamDataVIOAdaptor.cc:
##########
@@ -53,17 +57,17 @@ 
Http3StreamDataVIOAdaptor::handle_frame(std::shared_ptr<const Http3Frame> frame,
 void
 Http3StreamDataVIOAdaptor::finalize()
 {
-  SCOPED_MUTEX_LOCK(lock, this->_sink_vio->mutex, this_ethread());
-  MIOBuffer      *writer = this->_sink_vio->get_writer();
-  IOBufferReader *reader = this->_buffer->alloc_reader();
-  IOBufferBlock  *block;
-  while (reader->read_avail() > 0 && (block = reader->get_current_block()) != 
nullptr) {
-    writer->append_block(block);
-    reader->consume(block->size());
+  if (this->_finalized) {
+    return;
   }
 
-  this->_buffer->dealloc_reader(reader);
-  this->_sink_vio->nbytes = this->_total_data_length;
+  SCOPED_MUTEX_LOCK(lock, this->_sink_vio->mutex, this_ethread());
+  MIOBuffer *writer    = this->_sink_vio->get_writer();
+  int64_t    delivered = writer->write(this->_reader, 
this->_reader->read_avail());
+  this->_reader->consume(delivered);
+  this->_sink_vio->nbytes  = this->_total_data_length;
+  this->_sink_vio->ndone  += delivered;
+  this->_finalized         = true;

Review Comment:
   Fixed. The H3 header adaptor now accounts for bytes written into the sink 
VIO, and DATA finalization no longer sets nbytes to DATA payload length only. 
The read side now completes with nbytes == ndone after both headers and DATA 
have been produced, preserving the VIO accounting contract.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to