Skip to content

Commit

Permalink
Fix the backup helper
Browse files Browse the repository at this point in the history
  • Loading branch information
whitehawk committed Jun 11, 2024
1 parent d305ae9 commit 473216c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,21 @@ func DoCleanup() {
* Also, it is possible, that after EOF is issued (releasing the current reader process), but before the pipe is
* removed, a new reader process can start reading the pipe. To avoid such situation, we close the file handle
* after we have removed the file.
*
* Similar problem can happen with backup helper. If it finishes its work right after start, before opening the
* pipe for reading, the writing side will stay hanging on the other pipe's end. So, we also open and close the
* pipe to release the writing side.
*/
if *restoreAgent {
fileHandlePipe, err := os.OpenFile(pipeName, os.O_WRONLY|unix.O_NONBLOCK, os.ModeNamedPipe)
if err == nil {
defer fileHandlePipe.Close()
}
} else if *backupAgent {
fileHandlePipe, err := os.OpenFile(pipeName, os.O_RDONLY|unix.O_NONBLOCK, os.ModeNamedPipe)
if err == nil {
defer fileHandlePipe.Close()
}
}

err = deletePipe(pipeName)
Expand Down

0 comments on commit 473216c

Please sign in to comment.