Fix tus_file_shutdown

we removed an item from the tree while iterating it.

Spotted by flexelint with stricter rules, see follow up commits.

See tree(3bsd)
parent 569e6d5a
......@@ -679,11 +679,14 @@ tus_file_exp(struct tus_file_core **fcorep)
void
tus_file_shutdown(struct VPFX(tus_server) *srv)
{
struct tus_file_core *fcore;
struct tus_file_core *fcore, *next;
struct tus_files *files = tus_server_files(srv);
tus_server_lock(srv);
VSPLAY_FOREACH(fcore, tus_files, files) {
for (fcore = VSPLAY_MIN(tus_files, files);
fcore != NULL;
fcore = next) {
next = VSPLAY_NEXT(tus_files, files, fcore);
REPLACE(fcore->filename, NULL); // prevent unlink
Lck_Lock(&fcore->mtx);
tus_file_del_shutdown(&fcore);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment