]> git.ipfire.org Git - thirdparty/curl.git/commit
multi: do transfer book keeping using mid
authorStefan Eissing <stefan@eissing.org>
Tue, 25 Mar 2025 08:47:40 +0000 (09:47 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 17 Apr 2025 15:28:38 +0000 (17:28 +0200)
commit909af1a43b5a7fed8b5a4ca145e39f46b2f50325
treeeb438711e9b5c123a90d5947903eb5e196b8a125
parent02e9690c3ee2feb7c78c93c1c544c898df733383
multi: do transfer book keeping using mid

Change multi's book keeping of transfers to no longer use lists, but a
special table and bitsets for unsigned int values.

`multi-xfers` is the `uint_tbl` where `multi_add_handle()` inserts a new
transfer which assigns it a unique identifier `mid`. Use bitsets to keep
track of transfers that are in state "process" or "pending" or
"msgsent".

Use sparse bitsets to replace `conn->easyq` and event handlings tracking
of transfers per socket. Instead of pointers, keep the mids involved.

Provide base data structures and document them in docs/internal:
* `uint_tbl`: a table of transfers with `mid` as lookup key,
   handing out a mid for adds between 0 - capacity.
* `uint_bset`: a bitset keeping unsigned ints from 0 - capacity.
* `uint_spbset`: a sparse bitset for keeping a small number of
  unsigned int values
* `uint_hash`: for associating `mid`s with a pointer.

This makes the `mid` the recommended way to refer to transfers inside
the same multi without risk of running into a UAF.

Modifying table and bitsets is safe while iterating over them. Overall
memory requirements are lower as with the double linked list apprach.

Closes #16761
41 files changed:
.github/scripts/spellcheck.words
docs/Makefile.am
docs/internals/MID.md [new file with mode: 0644]
docs/internals/UINT_SETS.md [new file with mode: 0644]
include/curl/system.h
lib/Makefile.inc
lib/asyn.h
lib/conncache.c
lib/doh.c
lib/doh.h
lib/easy.c
lib/hash_offt.c
lib/hash_offt.h
lib/http2.c
lib/multi.c
lib/multi_ev.c
lib/multi_ev.h
lib/multihandle.h
lib/multiif.h
lib/share.c
lib/uint-bset.c [new file with mode: 0644]
lib/uint-bset.h [new file with mode: 0644]
lib/uint-spbset.c [new file with mode: 0644]
lib/uint-spbset.h [new file with mode: 0644]
lib/uint-table.c [new file with mode: 0644]
lib/uint-table.h [new file with mode: 0644]
lib/url.c
lib/urldata.h
lib/vquic/curl_msh3.c
lib/vquic/curl_ngtcp2.c
lib/vquic/curl_osslq.c
lib/vquic/curl_quiche.c
tests/data/Makefile.am
tests/data/test3211 [new file with mode: 0644]
tests/data/test3212 [new file with mode: 0644]
tests/data/test3213 [new file with mode: 0644]
tests/http/test_07_upload.py
tests/unit/Makefile.inc
tests/unit/unit3211.c [new file with mode: 0644]
tests/unit/unit3212.c [new file with mode: 0644]
tests/unit/unit3213.c [new file with mode: 0644]