From 785663decda969a202957802289784e311cf0b15 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@otacoo.com>
Date: Thu, 17 Mar 2016 22:30:42 +0900
Subject: [PATCH 1/3] Close file descriptor associated to backup_label
 correctly

The file descriptor used to generate the backup_label file was correctly
opened and written to, however it was never closed, causing a leak.
---
 src/bin/pg_rewind/pg_rewind.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c
index 96a42f8..c5589b9 100644
--- a/src/bin/pg_rewind/pg_rewind.c
+++ b/src/bin/pg_rewind/pg_rewind.c
@@ -584,6 +584,7 @@ createBackupLabel(XLogRecPtr startpoint, TimeLineID starttli, XLogRecPtr checkpo
 	/* TODO: move old file out of the way, if any. */
 	open_target_file("backup_label", true);		/* BACKUP_LABEL_FILE */
 	write_target_range(buf, 0, len);
+	close_target_file();
 }
 
 /*
-- 
2.7.3

