mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
now code compiles with -ansi -pedantic and has less warnings
This commit is contained in:
@@ -225,12 +225,12 @@ is_pg_dir(char *dir)
|
|||||||
struct stat sb;
|
struct stat sb;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
// test pgdata
|
/* test pgdata */
|
||||||
xsnprintf(path, buf_sz, "%s/PG_VERSION", dir);
|
xsnprintf(path, buf_sz, "%s/PG_VERSION", dir);
|
||||||
if (stat(path, &sb) == 0)
|
if (stat(path, &sb) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// test tablespace dir
|
/* test tablespace dir */
|
||||||
sprintf(path, "ls %s/PG_*/ -I*", dir);
|
sprintf(path, "ls %s/PG_*/ -I*", dir);
|
||||||
r = system(path);
|
r = system(path);
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
|
|||||||
2
config.h
2
config.h
@@ -44,6 +44,8 @@ typedef struct
|
|||||||
char pgctl_options[MAXLEN];
|
char pgctl_options[MAXLEN];
|
||||||
} t_configuration_options;
|
} 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_config(const char *config_file, t_configuration_options *options);
|
||||||
void parse_line(char *buff, char *name, char *value);
|
void parse_line(char *buff, char *name, char *value);
|
||||||
char *trim(char *s);
|
char *trim(char *s);
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ is_pgup(PGconn *conn, int timeout)
|
|||||||
{
|
{
|
||||||
if (twice)
|
if (twice)
|
||||||
return false;
|
return false;
|
||||||
PQreset(conn); // reconnect
|
PQreset(conn); /* reconnect */
|
||||||
twice = true;
|
twice = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -164,10 +164,10 @@ is_pgup(PGconn *conn, int timeout)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
failed:
|
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)
|
if (twice)
|
||||||
return false;
|
return false;
|
||||||
PQreset(conn); // reconnect
|
PQreset(conn); /* reconnect */
|
||||||
twice = true;
|
twice = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
repmgr.c
4
repmgr.c
@@ -85,8 +85,8 @@ bool need_a_node = true;
|
|||||||
bool require_password = false;
|
bool require_password = false;
|
||||||
|
|
||||||
/* Initialization of runtime options */
|
/* Initialization of runtime options */
|
||||||
t_runtime_options runtime_options = { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, "", "", 0 };
|
t_runtime_options runtime_options = T_RUNTIME_OPTIONS_INITIALIZER;
|
||||||
t_configuration_options options = { "", -1, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", -1, -1, -1, "", "" };
|
t_configuration_options options = T_CONFIGURATION_OPTIONS_INITIALIZER;
|
||||||
|
|
||||||
static char *server_mode = NULL;
|
static char *server_mode = NULL;
|
||||||
static char *server_cmd = NULL;
|
static char *server_cmd = NULL;
|
||||||
|
|||||||
2
repmgr.h
2
repmgr.h
@@ -69,6 +69,8 @@ typedef struct
|
|||||||
int keep_history;
|
int keep_history;
|
||||||
} t_runtime_options;
|
} t_runtime_options;
|
||||||
|
|
||||||
|
#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, "", "", 0 }
|
||||||
|
|
||||||
#define SLEEP_MONITOR 2
|
#define SLEEP_MONITOR 2
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
10
repmgrd.c
10
repmgrd.c
@@ -112,7 +112,7 @@ char *pid_file = NULL;
|
|||||||
* should initialize with {0} to be ANSI complaint ? but this raises
|
* should initialize with {0} to be ANSI complaint ? but this raises
|
||||||
* error with gcc -Wall
|
* error with gcc -Wall
|
||||||
*/
|
*/
|
||||||
t_configuration_options config = {};
|
t_configuration_options config = T_CONFIGURATION_OPTIONS_INITIALIZER;
|
||||||
|
|
||||||
static void help(const char* progname);
|
static void help(const char* progname);
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
@@ -220,7 +220,7 @@ main(int argc, char **argv)
|
|||||||
exit(ERR_SYS_FAILURE);
|
exit(ERR_SYS_FAILURE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0: // child process
|
case 0: /* child process */
|
||||||
pid = setsid();
|
pid = setsid();
|
||||||
if (pid == (pid_t)-1)
|
if (pid == (pid_t)-1)
|
||||||
{
|
{
|
||||||
@@ -229,7 +229,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: // parent process
|
default: /* parent process */
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -461,7 +461,7 @@ WitnessMonitor(void)
|
|||||||
* Check if the master is still available, if after 5 minutes of retries
|
* Check if the master is still available, if after 5 minutes of retries
|
||||||
* we cannot reconnect, return false.
|
* 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)
|
if (PQstatus(primaryConn) != CONNECTION_OK)
|
||||||
{
|
{
|
||||||
@@ -546,7 +546,7 @@ StandbyMonitor(void)
|
|||||||
* Check if the master is still available, if after 5 minutes of retries
|
* Check if the master is still available, if after 5 minutes of retries
|
||||||
* we cannot reconnect, try to get a new master.
|
* 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)
|
if (PQstatus(primaryConn) != CONNECTION_OK)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user