From 59b1924d5b2d190fc9bab7a8549e258db82d0ea5 Mon Sep 17 00:00:00 2001 From: Gianni Ciolli Date: Thu, 4 Aug 2016 20:59:47 +0200 Subject: [PATCH] Only collect remote command output if the caller requires it This addresses GitHub #216 and #167. --- repmgr.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/repmgr.c b/repmgr.c index 3dfe4310..5306d555 100644 --- a/repmgr.c +++ b/repmgr.c @@ -3453,7 +3453,7 @@ do_standby_switchover(void) remote_host, runtime_options.remote_user, command, - &command_output); + NULL); termPQExpBuffer(&command_output); @@ -5691,15 +5691,18 @@ remote_command(const char *host, const char *user, const char *command, PQExpBuf return false; } - /* TODO: better error handling */ - while (fgets(output, MAXLEN, fp) != NULL) + if (outputbuf != NULL) { - appendPQExpBuffer(outputbuf, "%s", output); + /* TODO: better error handling */ + while (fgets(output, MAXLEN, fp) != NULL) + { + appendPQExpBuffer(outputbuf, "%s", output); + } } - pclose(fp); - log_verbose(LOG_DEBUG, "remote_command(): output returned was:\n%s", outputbuf->data); + if (outputbuf != NULL) + log_verbose(LOG_DEBUG, "remote_command(): output returned was:\n%s", outputbuf->data); return true; }