Updated the sleep stuff
This commit is contained in:
parent
c59346ea68
commit
b0c8f04a53
@ -454,18 +454,21 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int result, attempt{0};
|
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 > 10) {
|
if(attempt > 50) {
|
||||||
std::cerr << "[CRITICAL] pthread_create(...) cause EAGAIN for the last 10 attempts! Aborting application execution!" << std::endl;
|
std::cerr << "[CRITICAL] pthread_create(...) cause EAGAIN for the last 50 attempts! 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();
|
||||||
}
|
}
|
||||||
std::cerr << "[CRITICAL] pthread_create(...) cause EAGAIN! Trying again in 5usec (Attempt: " << attempt << ")" << std::endl;
|
|
||||||
usleep(5);
|
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;
|
||||||
|
usleep(sleep);
|
||||||
attempt++;
|
attempt++;
|
||||||
|
sleep = (int) (sleep * 1.25);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user