Skip to content

Commit b441b28

Browse files
committed
fix: 进程终止时跳过 unload 避免 loader lock 死锁
1 parent 9125721 commit b441b28

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ unsafe extern "system" fn DllMain(h_module: HMODULE, reason: u32, _reserved: *mu
4646
);
4747
}
4848
DLL_PROCESS_DETACH => {
49-
loader::unload_mods();
49+
// _reserved 非 NULL = 进程正在终止 (ExitProcess)
50+
// 此时不能等待线程或做复杂清理,OS 会回收所有资源
51+
if _reserved.is_null() {
52+
// 动态卸载 (FreeLibrary),安全清理
53+
loader::unload_mods();
54+
}
5055
}
5156
_ => {}
5257
}

0 commit comments

Comments
 (0)