Skip to content

Commit 8131615

Browse files
committed
Avoid running init_config() more than once per process
Windows runs `DllMain` multiple times; when new threads are started, for instance. We want to run our `DllMain()` implementation only during process attachment (e.g. when the first thread loads it).
1 parent 2272604 commit 8131615

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/libblastrampoline.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ void * _win32_self_handle;
406406
BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD code, void *reserved) {
407407
if (code == DLL_PROCESS_ATTACH) {
408408
_win32_self_handle = (void *)hModule;
409+
} else {
410+
// We do not want to run our initialization more than once per process.
411+
return TRUE;
409412
}
410413
#else
411414
__attribute__((constructor)) void init(void) {

0 commit comments

Comments
 (0)