mirror of
https://github.com/rclone/rclone.git
synced 2026-01-03 09:03:50 +00:00
vfs: fix SIGHUP killing serve instead of flushing directory caches
Before, rclone serve would crash when sent a SIGHUP which contradicts the documentation - saying it should flush the directory caches. Moved signal handling from the mount into the vfs layer, which now handles SIGHUP on all uses of the VFS including mount and serve. Fixes #8607
This commit is contained in:
@@ -403,27 +403,7 @@ func (m *MountPoint) Wait() error {
|
||||
fnHandle := atexit.Register(finalise)
|
||||
defer atexit.Unregister(fnHandle)
|
||||
|
||||
// Reload VFS cache on SIGHUP
|
||||
sigHup := make(chan os.Signal, 1)
|
||||
NotifyOnSigHup(sigHup)
|
||||
var err error
|
||||
|
||||
waiting := true
|
||||
for waiting {
|
||||
select {
|
||||
// umount triggered outside the app
|
||||
case err = <-m.ErrChan:
|
||||
waiting = false
|
||||
// user sent SIGHUP to clear the cache
|
||||
case <-sigHup:
|
||||
root, err := m.VFS.Root()
|
||||
if err != nil {
|
||||
fs.Errorf(m.VFS.Fs(), "Error reading root: %v", err)
|
||||
} else {
|
||||
root.ForgetAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
err := <-m.ErrChan
|
||||
|
||||
finalise()
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
//go:build !plan9 && !js
|
||||
|
||||
package mountlib
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// NotifyOnSigHup makes SIGHUP notify given channel on supported systems
|
||||
func NotifyOnSigHup(sighupChan chan os.Signal) {
|
||||
signal.Notify(sighupChan, syscall.SIGHUP)
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
//go:build plan9 || js
|
||||
|
||||
package mountlib
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// NotifyOnSigHup makes SIGHUP notify given channel on supported systems
|
||||
func NotifyOnSigHup(sighupChan chan os.Signal) {}
|
||||
Reference in New Issue
Block a user