Increased sleep max
This commit is contained in:
parent
b0c8f04a53
commit
ce5d5c5cfa
@ -456,19 +456,26 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_
|
|||||||
|
|
||||||
int result, attempt{0}, sleep{5};
|
int result, attempt{0}, sleep{5};
|
||||||
while((result = original_pthread_create(thread, attr, start_routine, arg)) != 0 && errno == EAGAIN) {
|
while((result = original_pthread_create(thread, attr, start_routine, arg)) != 0 && errno == EAGAIN) {
|
||||||
if(attempt > 50) {
|
if(attempt > 55) {
|
||||||
std::cerr << "[CRITICAL] pthread_create(...) cause EAGAIN for the last 50 attempts! Aborting application execution!" << std::endl;
|
std::cerr << "[CRITICAL] pthread_create(...) cause EAGAIN for the last 50 attempts (~4.7seconds)! Aborting application execution!" << std::endl;
|
||||||
std::abort();
|
std::abort();
|
||||||
} else if(attempt > 5) {
|
} else if(attempt > 5) {
|
||||||
/* let some other threads do work */
|
/* let some other threads do work */
|
||||||
pthread_yield();
|
pthread_yield();
|
||||||
|
} else if(attempt == 0) {
|
||||||
|
std::string message{"[CRITICAL] Failed to spawn thread (Resource temporarily unavailable). Trying to recover."};
|
||||||
|
std::cerr << message << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string message{"[CRITICAL] pthread_create(...) cause EAGAIN! Trying again in " + std::to_string(sleep) + "usec (Attempt: " + std::to_string(attempt) + ")"};
|
//std::string message{"[CRITICAL] pthread_create(...) cause EAGAIN! Trying again in " + std::to_string(sleep) + "usec (Attempt: " + std::to_string(attempt) + ")"};
|
||||||
std::cerr << message << std::endl;
|
//std::cerr << message << std::endl;
|
||||||
usleep(sleep);
|
usleep(sleep);
|
||||||
attempt++;
|
attempt++;
|
||||||
sleep = (int) (sleep * 1.25);
|
sleep = (int) (sleep * 1.25);
|
||||||
}
|
}
|
||||||
|
if(attempt > 0) {
|
||||||
|
std::string message{"[CRITICAL] Successfully recovered from pthread_create() EAGAIN error. Took " + std::to_string(attempt) + " attempts."};
|
||||||
|
std::cerr << message << std::endl;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user