From 473216c2683a580a7dfe2bc752c73a205db1b213 Mon Sep 17 00:00:00 2001 From: Roman Eskin Date: Tue, 11 Jun 2024 17:20:50 +1000 Subject: [PATCH] Fix the backup helper --- helper/helper.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/helper/helper.go b/helper/helper.go index 50ff6559f..994751beb 100644 --- a/helper/helper.go +++ b/helper/helper.go @@ -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)