aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2016-10-25 18:57:56 +0200
committerMagnus Hagander <magnus@hagander.net>2016-10-25 19:00:12 +0200
commit78d109150bf133c38bcdc6d8c5bd9ff546ed1171 (patch)
treebbb92233571a8ee8322cd8f27b22500e51243301
parent8c46f0c9ce4695db7d68188e08e5e6be1c329645 (diff)
downloadpostgresql-78d109150bf133c38bcdc6d8c5bd9ff546ed1171.tar.gz
postgresql-78d109150bf133c38bcdc6d8c5bd9ff546ed1171.zip
Free walmethods before exiting
Not strictly necessary since we quite after, but could become important in the future if we do restarts etc. Michael Paquier with nitpicking from me
-rw-r--r--src/bin/pg_basebackup/pg_basebackup.c7
-rw-r--r--src/bin/pg_basebackup/pg_receivexlog.c4
-rw-r--r--src/bin/pg_basebackup/walmethods.c18
-rw-r--r--src/bin/pg_basebackup/walmethods.h4
4 files changed, 33 insertions, 0 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 16cab978d06..e2875df6334 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -495,6 +495,13 @@ LogStreamerMain(logstreamer_param *param)
}
PQfinish(param->bgconn);
+
+ if (format == 'p')
+ FreeWalDirectoryMethod();
+ else
+ FreeWalTarMethod();
+ pg_free(stream.walmethod);
+
return 0;
}
diff --git a/src/bin/pg_basebackup/pg_receivexlog.c b/src/bin/pg_basebackup/pg_receivexlog.c
index bbdf96edfd2..99445e65844 100644
--- a/src/bin/pg_basebackup/pg_receivexlog.c
+++ b/src/bin/pg_basebackup/pg_receivexlog.c
@@ -352,6 +352,10 @@ StreamLog(void)
}
PQfinish(conn);
+
+ FreeWalDirectoryMethod();
+ pg_free(stream.walmethod);
+
conn = NULL;
}
diff --git a/src/bin/pg_basebackup/walmethods.c b/src/bin/pg_basebackup/walmethods.c
index 632e095c4e8..1ecc23c2560 100644
--- a/src/bin/pg_basebackup/walmethods.c
+++ b/src/bin/pg_basebackup/walmethods.c
@@ -299,6 +299,13 @@ CreateWalDirectoryMethod(const char *basedir, bool sync)
return method;
}
+void
+FreeWalDirectoryMethod(void)
+{
+ pg_free(dir_data->basedir);
+ pg_free(dir_data);
+}
+
/*-------------------------------------------------------------------------
* WalTarMethod - write wal to a tar file containing pg_xlog contents
@@ -894,3 +901,14 @@ CreateWalTarMethod(const char *tarbase, int compression, bool sync)
return method;
}
+
+void
+FreeWalTarMethod(void)
+{
+ pg_free(tar_data->tarfilename);
+#ifdef HAVE_LIBZ
+ if (tar_data->compression)
+ pg_free(tar_data->zlibOut);
+#endif
+ pg_free(tar_data);
+}
diff --git a/src/bin/pg_basebackup/walmethods.h b/src/bin/pg_basebackup/walmethods.h
index 0c8eac7c619..8cea8ff4c05 100644
--- a/src/bin/pg_basebackup/walmethods.h
+++ b/src/bin/pg_basebackup/walmethods.h
@@ -43,3 +43,7 @@ struct WalWriteMethod
*/
WalWriteMethod *CreateWalDirectoryMethod(const char *basedir, bool sync);
WalWriteMethod *CreateWalTarMethod(const char *tarbase, int compression, bool sync);
+
+/* Cleanup routines for previously-created methods */
+void FreeWalDirectoryMethod(void);
+void FreeWalTarMethod(void);