dynstage: desperate safeguard for race against the linker
Even with LIBRARY_BUMP_DELAY, on some systems we'll try to reload the shared library too early. If dlopen fails, try to repeat it a few times with short but increasing delays. This should be extremely rare.
This commit is contained in:
parent
d74f54eb8e
commit
8927edae65
1 changed files with 17 additions and 4 deletions
|
@ -58,13 +58,26 @@ static struct {
|
|||
} dynstage;
|
||||
|
||||
static stageslib_t dynstage_dlopen(void) {
|
||||
stageslib_t lib = dlopen(TAISEI_BUILDCONF_DYNSTAGE_LIB, RTLD_NOW | RTLD_LOCAL);
|
||||
int attempts = 7;
|
||||
int delay = 10;
|
||||
|
||||
if(UNLIKELY(!lib)) {
|
||||
log_fatal("Failed to load stages library: %s", dlerror());
|
||||
for(;;) {
|
||||
stageslib_t lib = dlopen(TAISEI_BUILDCONF_DYNSTAGE_LIB, RTLD_NOW | RTLD_LOCAL);
|
||||
|
||||
if(LIKELY(lib != NULL)) {
|
||||
return lib;
|
||||
}
|
||||
|
||||
if(--attempts) {
|
||||
log_error("Failed to load stages library (%i attempt%s left): %s", attempts, attempts > 1? "s" : "", dlerror());
|
||||
SDL_Delay(delay);
|
||||
delay *= 2;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return lib;
|
||||
log_fatal("Failed to load stages library: %s", dlerror());
|
||||
}
|
||||
|
||||
static void dynstage_bump_lib_generation(void) {
|
||||
|
|
Loading…
Reference in a new issue