@@ -3241,20 +3241,21 @@ bool Session::Application::SendPendingData() {
32413241 return false ;
32423242 }
32433243
3244- // If stream_data.id is -1, then we're not serializing any data for any
3245- // specific stream. We still need to process QUIC session packets tho.
3246- if (stream_data.id > -1 )
3247- Debug (session (), " Serializing packets for stream id %" PRId64,
3248- stream_data.id );
3249- else
3250- Debug (session (), " Serializing session packets" );
3251-
32523244 // If the packet was sent previously, then packet will have been reset.
3253- if (!packet ) {
3245+ if (!pos ) {
32543246 packet = CreateStreamDataPacket ();
32553247 pos = packet->data ();
32563248 }
32573249
3250+ // If stream_data.id is -1, then we're not serializing any data for any
3251+ // specific stream. We still need to process QUIC session packets tho.
3252+ if (stream_data.id > -1 ) {
3253+ Debug (session (), " Serializing packets for stream id %" PRId64,
3254+ stream_data.id );
3255+ packet->AddRetained (stream_data.stream ->GetOutboundSource ());
3256+ } else
3257+ Debug (session (), " Requesting serialized packet flush" );
3258+
32583259 ssize_t nwrite = WriteVStream (&path, pos, &ndatalen, stream_data);
32593260 if (stream_data.id >= 0 ) {
32603261 Debug (session (),
@@ -3312,25 +3313,26 @@ bool Session::Application::SendPendingData() {
33123313 continue ;
33133314 }
33143315
3315- if (nwrite != 0 ){
3316+ if (nwrite != 0 ){ // -ve response i.e error
33163317 packet.reset ();
33173318 session ()->set_last_error (kQuicInternalError );
33183319 return false ;
3319- } else {
3320- if (stream_data.id >= 0 )
3321- ResumeStream (stream_data.id );
3322-
3323- // We are either congestion limited or done.
3324- if (pos - packet->data ()) {
3325- // Some data was serialized into the packet. We need to send it.
3326- packet->set_length (pos - packet->data ());
3327- Debug (session (), " Congestion limited, but %" PRIu64 " bytes pending" ,
3328- packet->length ());
3329- if (!session ()->SendPacket (std::move (packet), path))
3330- return false ;
3331- }
3332- return true ;
33333320 }
3321+
3322+ // 0 bytes in this sending operation
3323+ if (stream_data.id >= 0 )
3324+ ResumeStream (stream_data.id );
3325+
3326+ // We are either congestion limited or done.
3327+ if (pos - packet->data ()) {
3328+ // Some data was serialized into the packet. We need to send it.
3329+ packet->set_length (pos - packet->data ());
3330+ Debug (session (), " Congestion limited, but %" PRIu64 " bytes pending" ,
3331+ packet->length ());
3332+ if (!session ()->SendPacket (std::move (packet), path))
3333+ return false ;
3334+ }
3335+ return true ;
33343336 }
33353337
33363338 pos += nwrite;
@@ -3346,7 +3348,6 @@ bool Session::Application::SendPendingData() {
33463348 Debug (session (), " -- Failed to send packet" );
33473349 return false ;
33483350 }
3349- packet.reset ();
33503351 pos = nullptr ;
33513352 if (++packets_sent == kMaxPackets ) {
33523353 Debug (session (), " -- Max packets sent" );
0 commit comments