Skip to content

Commit df701d7

Browse files
committed
Minor bug in destroy loader, the loaders must be destroyed in inverse order.
1 parent 837584e commit df701d7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

source/loader/source/loader.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ void loader_unload_children()
811811
loader l = loader_singleton();
812812
uint64_t current = thread_id_get_current();
813813
size_t iterator, size = vector_size(l->initialization_order);
814-
vector queue = vector_create_type(loader_initialization_order);
814+
vector stack = vector_create_type(loader_initialization_order);
815815

816816
/* Get all loaders that have been initialized in the current thread */
817817
for (iterator = 0; iterator < size; ++iterator)
@@ -821,17 +821,17 @@ void loader_unload_children()
821821
if (order->being_deleted == 1 && order->impl != NULL && current == order->id)
822822
{
823823
/* Mark for deletion */
824-
vector_push_back(queue, &order);
824+
vector_push_back(stack, &order);
825825

826826
/* Start to delete the current loader */
827827
order->being_deleted = 0;
828828
}
829829
}
830830

831831
/* Free all loaders of the current thread and with BFS, look for children */
832-
while (vector_size(queue) != 0)
832+
while (vector_size(stack) != 0)
833833
{
834-
loader_initialization_order order = vector_front_type(queue, loader_initialization_order);
834+
loader_initialization_order order = vector_back_type(stack, loader_initialization_order);
835835

836836
log_write("metacall", LOG_LEVEL_DEBUG, "Loader unloading (%s)", loader_impl_tag(order->impl));
837837

@@ -843,10 +843,10 @@ void loader_unload_children()
843843
order->impl = NULL;
844844
order->id = THREAD_ID_INVALID;
845845

846-
vector_pop_front(queue);
846+
vector_pop_back(stack);
847847
}
848848

849-
vector_destroy(queue);
849+
vector_destroy(stack);
850850
}
851851

852852
int loader_unload()

0 commit comments

Comments
 (0)