Allow half a second for a working pidfile to be created and a tenth of a second for a daemon to bail.
This commit is contained in:
parent
2d7f57d462
commit
c30b64a63a
@ -13,7 +13,8 @@
|
|||||||
|
|
||||||
/* nano seconds */
|
/* nano seconds */
|
||||||
#define POLL_INTERVAL 20000000
|
#define POLL_INTERVAL 20000000
|
||||||
#define START_WAIT 500000000
|
#define WAIT_PIDFILE 500000000
|
||||||
|
#define START_WAIT 100000000
|
||||||
#define ONE_SECOND 1000000000
|
#define ONE_SECOND 1000000000
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -974,8 +975,8 @@ int start_stop_daemon (int argc, char **argv)
|
|||||||
if (START_WAIT > 0) {
|
if (START_WAIT > 0) {
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
int nloops = START_WAIT / POLL_INTERVAL;
|
int nloops = START_WAIT / POLL_INTERVAL;
|
||||||
|
int nloopsp = WAIT_PIDFILE / POLL_INTERVAL;
|
||||||
bool alive = false;
|
bool alive = false;
|
||||||
bool retestpid = false;
|
|
||||||
|
|
||||||
ts.tv_sec = 0;
|
ts.tv_sec = 0;
|
||||||
ts.tv_nsec = POLL_INTERVAL;
|
ts.tv_nsec = POLL_INTERVAL;
|
||||||
@ -989,6 +990,14 @@ int start_stop_daemon (int argc, char **argv)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We wait for a specific amount of time for a pidfile to be
|
||||||
|
* created. Once everything is in place we then wait some more
|
||||||
|
* to ensure that the daemon really is running and won't abort due
|
||||||
|
* to a config error. */
|
||||||
|
if (! background && pidfile && nloopsp)
|
||||||
|
nloopsp --;
|
||||||
|
else
|
||||||
nloops --;
|
nloops --;
|
||||||
|
|
||||||
/* This is knarly.
|
/* This is knarly.
|
||||||
@ -1005,9 +1014,8 @@ int start_stop_daemon (int argc, char **argv)
|
|||||||
/* The pidfile may not have been written yet - give it some time */
|
/* The pidfile may not have been written yet - give it some time */
|
||||||
if (get_pid (pidfile, true) == -1) {
|
if (get_pid (pidfile, true) == -1) {
|
||||||
alive = true;
|
alive = true;
|
||||||
retestpid = true;
|
|
||||||
} else {
|
} else {
|
||||||
retestpid = false;
|
nloopsp = 0;
|
||||||
if (do_stop (NULL, NULL, pidfile, uid, 0,
|
if (do_stop (NULL, NULL, pidfile, uid, 0,
|
||||||
true, false, true) > 0)
|
true, false, true) > 0)
|
||||||
alive = true;
|
alive = true;
|
||||||
@ -1022,12 +1030,6 @@ int start_stop_daemon (int argc, char **argv)
|
|||||||
if (! alive)
|
if (! alive)
|
||||||
eerrorx ("%s: %s died", applet, exec);
|
eerrorx ("%s: %s died", applet, exec);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retestpid) {
|
|
||||||
if (do_stop (NULL, NULL, pidfile, uid, 0, true,
|
|
||||||
false, true) < 1)
|
|
||||||
eerrorx ("%s: %s died", applet, exec);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (svcname)
|
if (svcname)
|
||||||
|
Loading…
Reference in New Issue
Block a user