Skip to content

Commit b101c8d

Browse files
authored
Merge pull request #24 from digitalocean/mdl-ovsdb-atomic
ovsdb: align atomics properly in Client
2 parents 206da1e + 03959cd commit b101c8d

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

ovsdb/client.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,28 @@ import (
3232
// A Client is an OVSDB client. Clients can be customized by using OptionFuncs
3333
// in the Dial and New functions.
3434
type Client struct {
35-
// The RPC connection, and its logger.
36-
c *jsonrpc.Conn
37-
ll *log.Logger
35+
// NB: must 64-bit align these atomic integers, so they should appear first
36+
// in the Client structure.
37+
// See: https://golang.org/pkg/sync/atomic/#pkg-note-BUG
3838

3939
// Incremented atomically when sending RPCs.
4040
rpcID int64
4141

42+
// Statistics about the echo loop.
43+
echoOK, echoFail int64
44+
45+
// All other types should occur after atomic integers.
46+
47+
// The RPC connection, and its logger.
48+
c *jsonrpc.Conn
49+
ll *log.Logger
50+
4251
// Callbacks for RPC responses.
4352
cbMu sync.RWMutex
4453
callbacks map[string]callback
4554

46-
// Interval at which echo RPCs should occur in the background, and statistics
47-
// about the echo loop.
48-
echoInterval time.Duration
49-
echoOK, echoFail int64
55+
// Interval at which echo RPCs should occur in the background.
56+
echoInterval time.Duration
5057

5158
// Track and clean up background goroutines.
5259
cancel func()

0 commit comments

Comments
 (0)