Skip to content

Commit 1885236

Browse files
committed
Simplify error handling in pg_tde_write_map_keydata_file()
1 parent 15ea835 commit 1885236

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

contrib/pg_tde/src/access/pg_tde_tdemap.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,6 @@ pg_tde_write_map_keydata_file(off_t file_size, char *file_data)
702702
char path_new[MAXPGPATH];
703703
int fd_new;
704704
off_t curr_pos = 0;
705-
bool is_err = false;
706705

707706
/* Let's get the header. Buff should start with the map file header. */
708707
fheader = (TDEFileHeader *) file_data;
@@ -717,23 +716,22 @@ pg_tde_write_map_keydata_file(off_t file_size, char *file_data)
717716
ereport(WARNING,
718717
errcode_for_file_access(),
719718
errmsg("could not write tde file \"%s\": %m", path_new));
720-
is_err = true;
721-
goto FINALIZE;
719+
close(fd_new);
720+
return;
722721
}
722+
723723
if (pg_fsync(fd_new) != 0)
724724
{
725725
ereport(WARNING,
726726
errcode_for_file_access(),
727727
errmsg("could not fsync file \"%s\": %m", path_new));
728-
is_err = true;
729-
goto FINALIZE;
728+
close(fd_new);
729+
return;
730730
}
731731

732-
FINALIZE:
733732
close(fd_new);
734733

735-
if (!is_err)
736-
finalize_key_rotation(db_map_path, path_new);
734+
finalize_key_rotation(db_map_path, path_new);
737735
}
738736

739737
/* It's called by seg_write inside crit section so no pallocs, hence

0 commit comments

Comments
 (0)