mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 00:46:29 +00:00
fix: now CloseConnections() is much more safe
This commit is contained in:
23
repmgrd.c
23
repmgrd.c
@@ -147,14 +147,21 @@ static void setup_event_handlers(void);
|
|||||||
static void do_daemonize();
|
static void do_daemonize();
|
||||||
static void check_and_create_pid_file(const char *pid_file);
|
static void check_and_create_pid_file(const char *pid_file);
|
||||||
|
|
||||||
#define CloseConnections() \
|
static void
|
||||||
if (PQisBusy(primaryConn) == 1) \
|
CloseConnections() {
|
||||||
(void) CancelQuery(primaryConn, local_options.master_response_timeout); \
|
if (primaryConn != NULL && PQisBusy(primaryConn) == 1)
|
||||||
if (myLocalConn != NULL) \
|
CancelQuery(primaryConn, local_options.master_response_timeout);
|
||||||
PQfinish(myLocalConn); \
|
|
||||||
if (primaryConn != NULL && primaryConn != myLocalConn) \
|
if (myLocalConn != NULL)
|
||||||
|
PQfinish(myLocalConn);
|
||||||
|
|
||||||
|
if (primaryConn != NULL && primaryConn != myLocalConn)
|
||||||
PQfinish(primaryConn);
|
PQfinish(primaryConn);
|
||||||
|
|
||||||
|
primaryConn = NULL;
|
||||||
|
myLocalConn = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
@@ -431,10 +438,6 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
/* Prevent a double-free */
|
|
||||||
if (primaryConn == myLocalConn)
|
|
||||||
myLocalConn = NULL;
|
|
||||||
|
|
||||||
/* close the connection to the database and cleanup */
|
/* close the connection to the database and cleanup */
|
||||||
CloseConnections();
|
CloseConnections();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user