Skip to content

Commit f51031a

Browse files
committed
Workaround for udev reader race condition (and panic)
If we try to close udev reader while an event is read it causes a panic in bufio. Workaround this problem by using CloseOnExec for the udev reader file descriptor. The descriptor is closed much later, at exec() when goroutines are stopped. So no race would happen. Closes #22 (hopefully)
1 parent ded149e commit f51031a

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Diff for: init/go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ require (
1616
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
1717
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
1818
)
19+
20+
// workaround for https://github.com/anatol/booster/issues/22
21+
replace github.com/s-urbaniak/uevent => github.com/stapelberg/uevent v1.0.1-0.20200422145418-40d619f351bf

Diff for: init/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T
145145
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
146146
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
147147
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
148-
github.com/s-urbaniak/uevent v1.0.0 h1:y1e40TmDfCU0l1o/MBpimGJgo2UzTTqBl/0GF6vx/io=
149-
github.com/s-urbaniak/uevent v1.0.0/go.mod h1:h83SVc1NQj/EubPaK4hWyiG217xLYr+fS+Jf10COrG0=
150148
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
151149
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
152150
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
@@ -161,6 +159,8 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6
161159
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
162160
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
163161
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
162+
github.com/stapelberg/uevent v1.0.1-0.20200422145418-40d619f351bf h1:Sj5ZN92aCALFDJhK/CT+VftmtSXAM27uBg6H+g7R9Hw=
163+
github.com/stapelberg/uevent v1.0.1-0.20200422145418-40d619f351bf/go.mod h1:txmMh4YRKuLIG6J2EBeGcACqbKUl5ZUYYOtguW4TqbM=
164164
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
165165
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
166166
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=

Diff for: init/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ func switchRoot() error {
429429
// Cleanup the state before handing off the machine to the new init
430430
func cleanup() {
431431
// We need to close our uevent connection, otherwise it will stay open forever and mess with the new init. .
432-
// See https://github.com/s-urbaniak/uevent/pull/1
433-
_ = udevReader.Close()
432+
// See https://github.com/s-urbaniak/uevent/pull/1 and https://github.com/anatol/booster/issues/22
433+
// _ = udevReader.Close()
434434

435435
shutdownNetwork()
436436
}

0 commit comments

Comments
 (0)