From 9056ba37925b7ecb4b5724633b1b288ed58951bd Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 30 May 2026 19:50:50 +0200 Subject: lib: Send stream FIN in the window The stream FIN was not gated on the flow control window, potentially causing a seqno overrun if the windows was full. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/frct.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/lib/frct.c') diff --git a/src/lib/frct.c b/src/lib/frct.c index cf1b60e2..3077df65 100644 --- a/src/lib/frct.c +++ b/src/lib/frct.c @@ -3789,6 +3789,15 @@ static int frcti_snd(struct frcti * frcti, return 0; } +/* Stream FIN is armed for rxm; needs to be in window. */ +static __inline__ bool stream_fin_blocked(struct frcti * frcti) +{ + if (!frcti->stream) + return false; + + return !before(frcti->snd_cr.seqno, frcti->snd_cr.lwe + RQ_SIZE); +} + /* * Stream: 0-byte FRCT_FIN DATA so peer's flow_read returns 0 at this * byte. Msg: control packet with FRCT_FIN flag, snd_cr.seqno carried @@ -3806,6 +3815,13 @@ static void frcti_fin_snd(struct frcti * frcti) pthread_rwlock_wrlock(&frcti->lock); already = frcti->snd_fin_sent; + + /* Defer before committing snd_fin_sent; linger loop retries. */ + if (!already && stream_fin_blocked(frcti)) { + pthread_rwlock_unlock(&frcti->lock); + return; + } + frcti->snd_fin_sent = true; fin_seqno = frcti->snd_cr.seqno; -- cgit v1.2.3