exit(1);
}
- if (status = sms_connect()) {
+ if (status = sms_connect("")) {
com_err(whoami, status, " on sms_connect");
leave("connect failed");
}
dfgen_prog, SMS_DIR, service);
gettimeofday(&tv, &tz);
if (status = sms_query("get_server_info", 1, qargv, getsvinfo, &svc)) {
- com_err(whoami, status, " getting service %s info", service);
+ com_err(whoami, status, " getting service %s info, skipping to next service", service);
+ continue;
}
svc.service = strsave(service);
qargv[0] = strsave(service);
com_err(whoami, status, " running %s", dfgen_prog);
waits.w_status = system(dfgen_cmd);
- /* extract the process's exit value */
- status = waits.w_retcode;
- if (status) {
- status += sms_err_base;
+ if (waits.w_termsig) {
+ status = SMS_TAR_FAIL;
+ com_err(whoami, status, " %s exited on signal %d",
+ dfgen_prog, waits.w_termsig);
+ } else if (waits.w_retcode) {
+ /* extract the process's exit value */
+ status = waits.w_retcode + sms_err_base;
com_err(whoami, status, " %s exited", dfgen_prog);
}
if (SOFT_FAIL(status)) {
qargv[3] = strsave("0");
status = sms_query("set_server_internal_flags", 6, qargv,
scream, NULL);
+ if (status) {
+ com_err(whoami, status,
+ " setting service state, trying again");
+ status = sms_query("set_server_internal_flags", 6, qargv,
+ scream, NULL);
+ if (status)
+ com_err(whoami, status, " setting service state again");
+ }
close(lock_fd);
free(qargv[0]);
free(qargv[1]);
}
if (!shost.enable || shost.hosterror ||
(shost.success && !shost.override &&
- shost.lastsuccess > svc->dfgen)) {
+ shost.lastsuccess >= svc->dfgen)) {
if (dbg & DBG_TRACE)
com_err(whoami, 0, "not updating %s:%s", svc->service, machine);
goto free_mach;
}
- if (!shost.success || shost.override ||
- shost.lasttry + svc->interval < tv.tv_sec) {
- lock_fd = maybe_lock_update(SMS_DIR, machine, svc->service, 1);
- if (lock_fd < 0)
- goto free_mach;
- argv[0] = svc->service;
- argv[1] = machine;
- argv[2] = argv[3] = argv[5] = "0";
- argv[4] = "1";
- argv[6] = strsave("");
- argv[7] = itoa(tv.tv_sec);
- argv[8] = itoa(shost.lastsuccess);
- status = sms_query("set_server_host_internal", 9, argv,scream,NULL);
- if (status != SMS_SUCCESS) {
- com_err(whoami,status," while setting internal state for %s:%s",
- svc->service, machine);
- goto free_mach;
- }
- status = sms_update_server(svc->service, machine, svc->target,
- svc->script);
- if (status == SMS_SUCCESS) {
- argv[2] = "0";
- argv[3] = "1";
- free(argv[8]);
- argv[8] = itoa(tv.tv_sec);
- } else if (SOFT_FAIL(status)) {
- free(argv[6]);
- argv[6] = strsave(error_message(status));
- } else { /* HARD_FAIL */
- argv[2] = itoa(shost.override);
- argv[5] = itoa(status);
- free(argv[6]);
- argv[6] = strsave(error_message(status));
- critical_alert("DCM", "DCM updating %s:%s: %s",
- machine, svc->service, argv[6]);
- if (!strcmp(svc->type, "REPLICAT")) {
- char *qargv[6];
-
- svc->harderror = status;
- svc->errmsg = strsave(argv[6]);
- qargv[0] = strsave(svc->service);
- qargv[1] = itoa(svc->dfgen);
- qargv[2] = itoa(svc->dfcheck);
- qargv[3] = strsave("0");
- qargv[4] = itoa(svc->harderror);
- qargv[5] = strsave(svc->errmsg);
+
+ lock_fd = maybe_lock_update(SMS_DIR, machine, svc->service, 1);
+ if (lock_fd < 0)
+ goto free_mach;
+ argv[0] = svc->service;
+ argv[1] = machine;
+ argv[2] = argv[3] = argv[5] = "0";
+ argv[4] = "1";
+ argv[6] = strsave("");
+ argv[7] = itoa(tv.tv_sec);
+ argv[8] = itoa(shost.lastsuccess);
+ status = sms_query("set_server_host_internal", 9, argv,scream,NULL);
+ if (status != SMS_SUCCESS) {
+ com_err(whoami,status," while setting internal state for %s:%s",
+ svc->service, machine);
+ goto free_mach;
+ }
+ status = sms_update_server(svc->service, machine, svc->target,
+ svc->script);
+ if (status == SMS_SUCCESS) {
+ argv[2] = "0";
+ argv[3] = "1";
+ free(argv[8]);
+ argv[8] = itoa(tv.tv_sec);
+ } else if (SOFT_FAIL(status)) {
+ free(argv[6]);
+ argv[6] = strsave(error_message(status));
+ } else { /* HARD_FAIL */
+ argv[2] = itoa(shost.override);
+ argv[5] = itoa(status);
+ free(argv[6]);
+ argv[6] = strsave(error_message(status));
+ critical_alert("DCM", "DCM updating %s:%s: %s",
+ machine, svc->service, argv[6]);
+ if (!strcmp(svc->type, "REPLICAT")) {
+ char *qargv[6];
+
+ svc->harderror = status;
+ svc->errmsg = strsave(argv[6]);
+ qargv[0] = strsave(svc->service);
+ qargv[1] = itoa(svc->dfgen);
+ qargv[2] = itoa(svc->dfcheck);
+ qargv[3] = strsave("0");
+ qargv[4] = itoa(svc->harderror);
+ qargv[5] = strsave(svc->errmsg);
+ status = sms_query("set_server_internal_flags",
+ 6, qargv, scream, NULL);
+ if (status) {
+ com_err(whoami, status,
+ " setting service state, trying again");
status = sms_query("set_server_internal_flags",
6, qargv, scream, NULL);
- free(qargv[0]);
- free(qargv[1]);
- free(qargv[2]);
- free(qargv[3]);
- free(qargv[4]);
- free(qargv[5]);
- close(lock_fd);
- free(argv[2]);
- argv[4] = "0";
- free(argv[5]);
- status = sms_query("set_server_host_internal",
- 9, argv,scream,NULL);
- return(-1);
+ if (status)
+ com_err(whoami, status, " setting service state again");
}
+ free(qargv[0]);
+ free(qargv[1]);
+ free(qargv[2]);
+ free(qargv[3]);
+ free(qargv[4]);
+ free(qargv[5]);
+ close(lock_fd);
free(argv[2]);
+ argv[4] = "0";
free(argv[5]);
+ status = sms_query("set_server_host_internal",
+ 9, argv,scream,NULL);
+ if (status) {
+ com_err(whoami, status,
+ " setting host state, trying again");
+ status = sms_query("set_server_host_internal",
+ 9, argv,scream,NULL);
+ if (status)
+ com_err(whoami, status, " setting host state again");
+ }
+ return(-1);
}
- argv[4] = "0";
- close(lock_fd);
+ free(argv[2]);
+ free(argv[5]);
+ }
+ argv[4] = "0";
+ close(lock_fd);
+ status = sms_query("set_server_host_internal", 9, argv,scream,NULL);
+ if (status) {
+ com_err(whoami, status, " setting host state, trying again");
status = sms_query("set_server_host_internal", 9, argv,scream,NULL);
- } else {
- if (dbg & DBG_TRACE)
- com_err(whoami, 0, "not updating %s", machine);
+ if (status)
+ com_err(whoami, status, " setting host state again");
}
free_mach:
free(machine);
}
return(0);
}
-