Imported Upstream version 2.7.2
This commit is contained in:
parent
0121794af9
commit
a356b56d11
263 changed files with 6039 additions and 8151 deletions
|
|
@ -45,6 +45,12 @@ static int maxsdorder = 0, testmode = 0, exec_error = 0;
|
|||
/* timer - keeps us from getting stuck if a driver hangs */
|
||||
static int maxstartdelay = 45;
|
||||
|
||||
/* counter - retry that many time(s) to start the driver if it fails to */
|
||||
static int maxretry = 1;
|
||||
|
||||
/* timer - delay between each restart attempt of the driver(s) */
|
||||
static int retrydelay = 5;
|
||||
|
||||
/* Directory where driver executables live */
|
||||
static char *driverpath = NULL;
|
||||
|
||||
|
|
@ -65,6 +71,12 @@ void do_upsconf_args(char *upsname, char *var, char *val)
|
|||
driverpath = xstrdup(val);
|
||||
}
|
||||
|
||||
if (!strcmp(var, "maxretry"))
|
||||
maxretry = atoi(val);
|
||||
|
||||
if (!strcmp(var, "retrydelay"))
|
||||
retrydelay = atoi(val);
|
||||
|
||||
/* ignore anything else - it's probably for main */
|
||||
|
||||
return;
|
||||
|
|
@ -248,6 +260,7 @@ static void start_driver(const ups_t *ups)
|
|||
char *argv[8];
|
||||
char dfn[SMALLBUF];
|
||||
int ret, arg = 0;
|
||||
int initial_exec_error = exec_error, drv_maxretry = maxretry;
|
||||
struct stat fs;
|
||||
|
||||
upsdebugx(1, "Starting UPS: %s", ups->upsname);
|
||||
|
|
@ -276,10 +289,28 @@ static void start_driver(const ups_t *ups)
|
|||
/* tie it off */
|
||||
argv[arg++] = NULL;
|
||||
|
||||
debugcmdline(2, "exec: ", argv);
|
||||
|
||||
if (!testmode) {
|
||||
forkexec(argv, ups);
|
||||
while (drv_maxretry > 0) {
|
||||
int cur_exec_error = exec_error;
|
||||
|
||||
upsdebugx(2, "%i remaining attempts", drv_maxretry);
|
||||
debugcmdline(2, "exec: ", argv);
|
||||
drv_maxretry--;
|
||||
|
||||
if (!testmode) {
|
||||
forkexec(argv, ups);
|
||||
}
|
||||
|
||||
/* driver command succeeded */
|
||||
if (cur_exec_error == exec_error) {
|
||||
drv_maxretry = 0;
|
||||
exec_error = initial_exec_error;
|
||||
}
|
||||
else {
|
||||
/* otherwise, retry if still needed */
|
||||
if (drv_maxretry > 0)
|
||||
sleep (retrydelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue