提交 26bfcd4e 编写于 作者: D Daniel Gustafsson 提交者: Xin Zhang

Close files on retries before returning from function

There were windows where we could return with open filehandles,
ensure that we always close up and free up resources on retries
before exiting.
上级 b966b06f
......@@ -258,6 +258,18 @@ compare_files(char *primaryfilepath, char *mirrorfilepath, RelfilenodeEntry *ren
retry:
CHECK_FOR_INTERRUPTS();
/* If the files were still open from previous attempt, close them first. */
if (primaryFile != -1)
{
FileClose(primaryFile);
primaryFile = -1;
}
if (mirrorFile != -1)
{
FileClose(mirrorFile);
mirrorFile = -1;
}
if (attempts == NUM_RETRIES)
{
ereport(WARNING,
......@@ -279,18 +291,6 @@ retry:
return false;
}
/* If the files were still open from previous attempt, close them first. */
if (primaryFile != -1)
{
FileClose(primaryFile);
primaryFile = -1;
}
if (mirrorFile != -1)
{
FileClose(mirrorFile);
mirrorFile = -1;
}
/*
* Attempt to open both files.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册