Skip to content

Commit 41e2e2b

Browse files
authored
vine: remove items after iterating hash table (#4083)
* remove items after iterating hash table * lint * use list to collect removable items
1 parent 799c4ac commit 41e2e2b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

taskvine/src/manager/vine_current_transfers.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,27 @@ int vine_current_transfers_wipe_worker(struct vine_manager *q, struct vine_worke
214214
return removed;
215215
}
216216

217+
struct list *ids_to_remove = list_create();
218+
217219
char *id;
218220
struct vine_transfer_pair *t;
219221
HASH_TABLE_ITERATE(q->current_transfer_table, id, t)
220222
{
221223
if (t->to == w || t->source_worker == w) {
222-
vine_current_transfers_remove(q, id);
223-
removed++;
224+
list_push_tail(ids_to_remove, xxstrdup(id));
224225
}
225226
}
226227

228+
list_first_item(ids_to_remove);
229+
char *transfer_id;
230+
while ((transfer_id = list_pop_head(ids_to_remove))) {
231+
vine_current_transfers_remove(q, transfer_id);
232+
free(transfer_id);
233+
removed++;
234+
}
235+
236+
list_delete(ids_to_remove);
237+
227238
return removed;
228239
}
229240

0 commit comments

Comments
 (0)