Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
3707b10b
Unverified
Commit
3707b10b
authored
Oct 11, 2017
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The DBusFakeConnection should have locks to prevent races
Otherwise tests that use dbus signals fail race detection.
parent
bd5eeb10
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
fake_dbus.go
pkg/util/dbus/fake_dbus.go
+6
-0
No files found.
pkg/util/dbus/fake_dbus.go
View file @
3707b10b
...
...
@@ -18,6 +18,7 @@ package dbus
import
(
"fmt"
"sync"
godbus
"github.com/godbus/dbus"
)
...
...
@@ -30,6 +31,7 @@ type DBusFake struct {
// DBusFakeConnection represents a fake D-Bus connection
type
DBusFakeConnection
struct
{
lock
sync
.
Mutex
busObject
*
fakeObject
objects
map
[
string
]
*
fakeObject
signalHandlers
[]
chan
<-
*
godbus
.
Signal
...
...
@@ -88,6 +90,8 @@ func (conn *DBusFakeConnection) Object(name, path string) Object {
// Signal is part of the Connection interface
func
(
conn
*
DBusFakeConnection
)
Signal
(
ch
chan
<-
*
godbus
.
Signal
)
{
conn
.
lock
.
Lock
()
defer
conn
.
lock
.
Unlock
()
for
i
:=
range
conn
.
signalHandlers
{
if
conn
.
signalHandlers
[
i
]
==
ch
{
conn
.
signalHandlers
=
append
(
conn
.
signalHandlers
[
:
i
],
conn
.
signalHandlers
[
i
+
1
:
]
...
)
...
...
@@ -109,6 +113,8 @@ func (conn *DBusFakeConnection) AddObject(name, path string, handler DBusFakeHan
// EmitSignal emits a signal on conn
func
(
conn
*
DBusFakeConnection
)
EmitSignal
(
name
,
path
,
iface
,
signal
string
,
args
...
interface
{})
{
conn
.
lock
.
Lock
()
defer
conn
.
lock
.
Unlock
()
sig
:=
&
godbus
.
Signal
{
Sender
:
name
,
Path
:
godbus
.
ObjectPath
(
path
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment