Skip to content

Commit 0233532

Browse files
committed
snapshot: prevent duplicate calls to mount returning different values
In addition to being wasteful, without this, concurrent calls to `Mount` would have lost the previous `target` and so would never have been removed. Signed-off-by: Justin Chadwell <[email protected]>
1 parent 8fa331f commit 0233532

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

snapshot/localmounter_darwin.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ func (lm *localMounter) Mount() (string, error) {
1313
lm.mu.Lock()
1414
defer lm.mu.Unlock()
1515

16+
if lm.target != "" {
17+
return lm.target, nil
18+
}
19+
1620
if lm.mounts == nil && lm.mountable != nil {
1721
mounts, release, err := lm.mountable.Mount()
1822
if err != nil {

snapshot/localmounter_freebsd.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ func (lm *localMounter) Mount() (string, error) {
1212
lm.mu.Lock()
1313
defer lm.mu.Unlock()
1414

15+
if lm.target != "" {
16+
return lm.target, nil
17+
}
18+
1519
if lm.mounts == nil && lm.mountable != nil {
1620
mounts, release, err := lm.mountable.Mount()
1721
if err != nil {

snapshot/localmounter_linux.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ func (lm *localMounter) Mount() (string, error) {
1616
lm.mu.Lock()
1717
defer lm.mu.Unlock()
1818

19+
if lm.target != "" {
20+
return lm.target, nil
21+
}
22+
1923
if lm.mounts == nil && lm.mountable != nil {
2024
mounts, release, err := lm.mountable.Mount()
2125
if err != nil {

snapshot/localmounter_windows.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ func (lm *localMounter) Mount() (string, error) {
1616
lm.mu.Lock()
1717
defer lm.mu.Unlock()
1818

19+
if lm.target != "" {
20+
return lm.target, nil
21+
}
22+
1923
if lm.mounts == nil && lm.mountable != nil {
2024
mounts, release, err := lm.mountable.Mount()
2125
if err != nil {

0 commit comments

Comments
 (0)