@@ -37,7 +37,7 @@ type Client struct {
3737 ll * log.Logger
3838
3939 // Incremented atomically when sending RPCs.
40- rpcID * int64
40+ rpcID int64
4141
4242 // Callbacks for RPC responses.
4343 cbMu sync.RWMutex
@@ -46,7 +46,7 @@ type Client struct {
4646 // Interval at which echo RPCs should occur in the background, and statistics
4747 // about the echo loop.
4848 echoInterval time.Duration
49- echoOK , echoFail * int64
49+ echoOK , echoFail int64
5050
5151 // Track and clean up background goroutines.
5252 cancel func ()
@@ -100,21 +100,12 @@ func New(conn net.Conn, options ...OptionFunc) (*Client, error) {
100100 }
101101 }
102102
103- // Set up RPC request IDs.
104- var rpcID int64
105- client .rpcID = & rpcID
106-
107103 // Set up the JSON-RPC connection.
108104 client .c = jsonrpc .NewConn (conn , client .ll )
109105
110106 // Set up callbacks.
111107 client .callbacks = make (map [string ]callback )
112108
113- // Set up echo loop statistics.
114- var echoOK , echoFail int64
115- client .echoOK = & echoOK
116- client .echoFail = & echoFail
117-
118109 // Coordinates the sending of echo messages among multiple goroutines.
119110 echoC := make (chan struct {})
120111
@@ -155,7 +146,7 @@ func New(conn net.Conn, options ...OptionFunc) (*Client, error) {
155146func (c * Client ) requestID () string {
156147 // We use integer IDs by convention, but OVSDB happily accepts
157148 // any non-null JSON value.
158- return strconv .FormatInt (atomic .AddInt64 (c .rpcID , 1 ), 10 )
149+ return strconv .FormatInt (atomic .AddInt64 (& c .rpcID , 1 ), 10 )
159150}
160151
161152// Close closes a Client's connection and cleans up its resources.
@@ -174,8 +165,8 @@ func (c *Client) Stats() ClientStats {
174165 s .Callbacks .Current = len (c .callbacks )
175166 c .cbMu .RUnlock ()
176167
177- s .EchoLoop .Success = int (atomic .LoadInt64 (c .echoOK ))
178- s .EchoLoop .Failure = int (atomic .LoadInt64 (c .echoFail ))
168+ s .EchoLoop .Success = int (atomic .LoadInt64 (& c .echoOK ))
169+ s .EchoLoop .Failure = int (atomic .LoadInt64 (& c .echoFail ))
179170
180171 return s
181172}
@@ -361,11 +352,11 @@ func (c *Client) echoLoop(ctx context.Context, echoC <-chan struct{}) {
361352 }
362353
363354 // Count other errors as failures.
364- atomic .AddInt64 (c .echoFail , 1 )
355+ atomic .AddInt64 (& c .echoFail , 1 )
365356 continue
366357 }
367358
368- atomic .AddInt64 (c .echoOK , 1 )
359+ atomic .AddInt64 (& c .echoOK , 1 )
369360 }
370361}
371362
0 commit comments