summaryrefslogtreecommitdiff
diff options
authorMichael Vogt <mvo@ubuntu.com>2018-11-13 20:33:32 +0100
committerMichael Vogt <mvo@ubuntu.com>2018-11-13 20:33:32 +0100
commit187db70f2ecfb769d7a6e1629a1c79505dcba88f (patch)
tree9f07ed5519800a36bc2b7fc3aa3c1702c0104397
parent38b3da38a8f2a12f3d6fedfc960258600ed3af91 (diff)
gpio: fix race with the mockingfix/lp-1802581-3
-rw-r--r--interfaces/builtin/gpio.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/interfaces/builtin/gpio.go b/interfaces/builtin/gpio.go
index 766d0ff8c7..2f723d0fff 100644
--- a/interfaces/builtin/gpio.go
+++ b/interfaces/builtin/gpio.go
@@ -23,6 +23,7 @@ import (
"fmt"
"os"
"strconv"
+ "time"
"github.com/snapcore/snapd/interfaces"
"github.com/snapcore/snapd/interfaces/apparmor"
@@ -117,6 +118,16 @@ func (iface *gpioInterface) AppArmorConnectedPlug(spec *apparmor.Specification,
return err
}
}
+ // give the kernel/mock a bit of time to export the device
+ for i := 0; i < 100; i++ {
+ if osutil.FileExists(path) {
+ break
+ }
+ time.Sleep(100 * time.Millisecond)
+ }
+ if !osutil.FileExists(path) {
+ return fmt.Errorf("%q was not created", path)
+ }
}
// Entries in /sys/class/gpio for single GPIO's are just symlinks