aboutsummaryrefslogtreecommitdiff
path: root/src/nssync.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nssync.c')
-rw-r--r--src/nssync.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/nssync.c b/src/nssync.c
index 75de83c..3eb5540 100644
--- a/src/nssync.c
+++ b/src/nssync.c
@@ -309,13 +309,22 @@ synchronize(struct nssync *sp)
void
check_slave_status()
{
- FILE *fp = fopen(slave_status_file, "r");
+ FILE *fp;
char *saved_file = NULL;
char *saved_off;
char *buf = NULL;
size_t size = 0;
char *sql_file, *sql_off;
+
+ if (!slave_status_file)
+ return;
+ if (sql_get_slave_status(&sql_file, &sql_off)) {
+ unlink(slave_status_file);
+ return;
+ }
+
+ fp = fopen(slave_status_file, "r");
if (fp) {
if (grecs_getline(&buf, &size, fp) > 0) {
buf[strlen(buf)-1] = 0;
@@ -327,9 +336,7 @@ check_slave_status()
fclose(fp);
}
- if (sql_get_slave_status(&sql_file, &sql_off))
- unlink(slave_status_file);
- else if (!force && saved_file && saved_off &&
+ if (!force && saved_file && saved_off &&
strcmp(sql_file, saved_file) == 0 &&
strcmp(sql_off, saved_off) == 0) {
debug(1, ("slave status hasn't changed: nothing to do"));
@@ -429,8 +436,7 @@ main(int argc, char **argv)
check_pidfile();
- if (slave_status_file)
- check_slave_status();
+ check_slave_status();
for (ep = synclist->head; ep; ep = ep->next)
synchronize(ep->data);

Return to:

Send suggestions and report system problems to the System administrator.