commit d85d8e86350e1788ad5f8915ba9eb64e9d718bcc
parent b5a3c4e34cd9387fb71199ac2bc8845fddc63899
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Wed, 26 Aug 2026 18:54:11 +0200
HTTP/2: fixed clean-up at connection closing
Diffstat:
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/mhd2/h2/h2_conn_streams.c b/src/mhd2/h2/h2_conn_streams.c
@@ -694,16 +694,22 @@ mhd_h2_conn_close_streams_all (struct MHD_Connection *restrict c)
while (!0)
{
struct mhd_H2Stream *const s =
- mhd_DLINKEDL_GET_FIRST_D (&(c->h2.streams.send_q));
+ mhd_DLINKEDL_GET_FIRST_D (&(c->h2.streams.active));
if (NULL == s)
break;
- mhd_assert (!stream_is_closed (s));
+ /* The "active" list is the owner of the streams, while the sending queue
+ holds only the streams with the data to be sent.
+ The stream is in the sending queue if it has the next element in
+ the queue or if it is the last element of the queue. */
+ if ((NULL != mhd_DLINKEDL_GET_NEXT (s, send_q))
+ || (s == mhd_DLINKEDL_GET_LAST_D (&(c->h2.streams.send_q))))
+ mhd_DLINKEDL_DEL_D (&(c->h2.streams.send_q), s, send_q);
- mhd_DLINKEDL_DEL_D (&(c->h2.streams.send_q), s, send_q);
conn_remove_stream (c,
s);
}
mhd_assert (0u == c->h2.streams.num_streams);
+ mhd_assert (NULL == mhd_DLINKEDL_GET_FIRST_D (&(c->h2.streams.send_q)));
}