diff --git a/check_dir.c b/check_dir.c index 11aa56bb..f578b4e1 100644 --- a/check_dir.c +++ b/check_dir.c @@ -225,12 +225,12 @@ is_pg_dir(char *dir) struct stat sb; int r; - // test pgdata + /* test pgdata */ xsnprintf(path, buf_sz, "%s/PG_VERSION", dir); if (stat(path, &sb) == 0) return true; - // test tablespace dir + /* test tablespace dir */ sprintf(path, "ls %s/PG_*/ -I*", dir); r = system(path); if (r == 0) diff --git a/config.h b/config.h index cd4e9a7d..8c8bbea1 100644 --- a/config.h +++ b/config.h @@ -44,6 +44,8 @@ typedef struct char pgctl_options[MAXLEN]; } t_configuration_options; +#define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", -1, -1, -1, "", "" } + void parse_config(const char *config_file, t_configuration_options *options); void parse_line(char *buff, char *name, char *value); char *trim(char *s); diff --git a/dbutils.c b/dbutils.c index 9157a6e9..51d768e2 100644 --- a/dbutils.c +++ b/dbutils.c @@ -138,7 +138,7 @@ is_pgup(PGconn *conn, int timeout) { if (twice) return false; - PQreset(conn); // reconnect + PQreset(conn); /* reconnect */ twice = true; } else @@ -164,10 +164,10 @@ is_pgup(PGconn *conn, int timeout) break; failed: - // we need to retry, because we might just have loose the connection once + /* we need to retry, because we might just have loose the connection once */ if (twice) return false; - PQreset(conn); // reconnect + PQreset(conn); /* reconnect */ twice = true; } } diff --git a/repmgr.c b/repmgr.c index aa7f1acc..40e964ad 100644 --- a/repmgr.c +++ b/repmgr.c @@ -85,8 +85,8 @@ bool need_a_node = true; bool require_password = false; /* Initialization of runtime options */ -t_runtime_options runtime_options = { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, "", "", 0 }; -t_configuration_options options = { "", -1, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", -1, -1, -1, "", "" }; +t_runtime_options runtime_options = T_RUNTIME_OPTIONS_INITIALIZER; +t_configuration_options options = T_CONFIGURATION_OPTIONS_INITIALIZER; static char *server_mode = NULL; static char *server_cmd = NULL; diff --git a/repmgr.h b/repmgr.h index 295a4645..a2a0ac8e 100644 --- a/repmgr.h +++ b/repmgr.h @@ -69,6 +69,8 @@ typedef struct int keep_history; } t_runtime_options; +#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, "", "", 0 } + #define SLEEP_MONITOR 2 #endif diff --git a/repmgrd.c b/repmgrd.c index 4c88457b..8b521fca 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -112,7 +112,7 @@ char *pid_file = NULL; * should initialize with {0} to be ANSI complaint ? but this raises * error with gcc -Wall */ -t_configuration_options config = {}; +t_configuration_options config = T_CONFIGURATION_OPTIONS_INITIALIZER; static void help(const char* progname); static void usage(void); @@ -220,7 +220,7 @@ main(int argc, char **argv) exit(ERR_SYS_FAILURE); break; - case 0: // child process + case 0: /* child process */ pid = setsid(); if (pid == (pid_t)-1) { @@ -229,7 +229,7 @@ main(int argc, char **argv) } break; - default: // parent process + default: /* parent process */ exit(0); } } @@ -461,7 +461,7 @@ WitnessMonitor(void) * Check if the master is still available, if after 5 minutes of retries * we cannot reconnect, return false. */ - CheckPrimaryConnection(); // this take up to local_options.reconnect_attempts * local_options.reconnect_intvl seconds + CheckPrimaryConnection(); /* this take up to local_options.reconnect_attempts * local_options.reconnect_intvl seconds */ if (PQstatus(primaryConn) != CONNECTION_OK) { @@ -546,7 +546,7 @@ StandbyMonitor(void) * Check if the master is still available, if after 5 minutes of retries * we cannot reconnect, try to get a new master. */ - CheckPrimaryConnection(); // this take up to local_options.reconnect_attempts * local_options.reconnect_intvl seconds + CheckPrimaryConnection(); /* this take up to local_options.reconnect_attempts * local_options.reconnect_intvl seconds */ if (PQstatus(primaryConn) != CONNECTION_OK) {