correctly close module file handles on module unloading in new demon layer

This commit is contained in:
Ryan Fleury
2024-03-27 11:19:24 -07:00
parent d73a3d4196
commit 4899f1871b
3 changed files with 11 additions and 5 deletions
+1 -2
View File
@@ -365,8 +365,7 @@ dbgi_binary_close(String8 exe_path)
if(need_deletion) for(;;)
{
os_rw_mutex_drop_w(stripe->rw_mutex);
for(U64 start_t = os_now_microseconds();
os_now_microseconds() <= start_t + 250;);
for(U64 start_t = os_now_microseconds(); os_now_microseconds() <= start_t + 250;);
os_rw_mutex_take_w(stripe->rw_mutex);
if(binary->refcount == 0 && ins_atomic_u64_eval(&binary->scope_touch_count) == 0)
{
+4
View File
@@ -151,6 +151,10 @@ dmn_w32_entity_release(DMN_W32_Entity *entity)
// rjf: free entity
SLLStackPush(dmn_w32_shared->entities_first_free, t->e);
t->e->gen += 1;
if(t->e->kind == DMN_W32_EntityKind_Module)
{
CloseHandle(t->e->handle);
}
// rjf: remove from id -> entity map
if(t->e->id != 0)
+6 -3
View File
@@ -678,7 +678,8 @@ os_file_close(OS_Handle file)
{
if(os_handle_match(file, os_handle_zero())) { return; }
HANDLE handle = (HANDLE)file.u64[0];
CloseHandle(handle);
BOOL result = CloseHandle(handle);
(void)result;
}
internal U64
@@ -896,7 +897,8 @@ internal void
os_file_map_close(OS_Handle map)
{
HANDLE handle = (HANDLE)map.u64[0];
CloseHandle(handle);
BOOL result = CloseHandle(handle);
(void)result;
}
internal void *
@@ -939,7 +941,8 @@ os_file_map_view_open(OS_Handle map, OS_AccessFlags flags, Rng1U64 range)
internal void
os_file_map_view_close(OS_Handle map, void *ptr)
{
UnmapViewOfFile(ptr);
BOOL result = UnmapViewOfFile(ptr);
(void)result;
}
//- rjf: directory iteration