fixed sleep in daemons throttle code, sleep() only accepts unsigned int, but in some cases uWSGI could pass value < 0

This commit is contained in:
Łukasz Mierzwa
2013-10-18 22:33:48 +02:00
parent 389d0b95d5
commit b06e35c610
+3 -1
View File
@@ -263,6 +263,8 @@ void uwsgi_spawn_daemon(struct uwsgi_daemon *ud) {
if (uwsgi.current_time - ud->last_spawn <= 3) {
throttle = ud->respawns - (uwsgi.current_time - ud->last_spawn);
// if ud->respawns == 0 then we can end up with throttle < 0
if (throttle <= 0) throttle = 1;
}
pid_t pid = uwsgi_fork("uWSGI external daemon");
@@ -323,7 +325,7 @@ void uwsgi_spawn_daemon(struct uwsgi_daemon *ud) {
if (throttle) {
uwsgi_log("[uwsgi-daemons] throttling \"%s\" for %d seconds\n", ud->command, throttle);
sleep(throttle);
sleep((unsigned int) throttle);
}
uwsgi_log("[uwsgi-daemons] %sspawning \"%s\"\n", ud->respawns > 0 ? "re" : "", ud->command);