Commit ae9dcc28 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Retry unmount to cater for device busy race conditions.

parent 73f1d740
......@@ -94,9 +94,20 @@ func (me *MountState) SetRecordStatistics(record bool) {
}
}
func (me *MountState) Unmount() error {
// Todo: flush/release all files/dirs?
err := unmount(me.mountPoint)
func (me *MountState) Unmount() (err error) {
delay := int64(0)
for try := 0; try < 3; try++ {
err = unmount(me.mountPoint)
if err == nil {
break
}
// Sleep for a bit. This is not pretty, but there is
// no way we can be certain that the kernel thinks all
// open files have already been closed.
delay = 2*delay + 1e6
time.Sleep(delay)
}
if err == nil {
me.mountPoint = ""
me.mountFile.Close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment