@@ -37,7 +37,7 @@ type Client struct {
37
37
ll * log.Logger
38
38
39
39
// Incremented atomically when sending RPCs.
40
- rpcID * int64
40
+ rpcID int64
41
41
42
42
// Callbacks for RPC responses.
43
43
cbMu sync.RWMutex
@@ -46,7 +46,7 @@ type Client struct {
46
46
// Interval at which echo RPCs should occur in the background, and statistics
47
47
// about the echo loop.
48
48
echoInterval time.Duration
49
- echoOK , echoFail * int64
49
+ echoOK , echoFail int64
50
50
51
51
// Track and clean up background goroutines.
52
52
cancel func ()
@@ -100,21 +100,12 @@ func New(conn net.Conn, options ...OptionFunc) (*Client, error) {
100
100
}
101
101
}
102
102
103
- // Set up RPC request IDs.
104
- var rpcID int64
105
- client .rpcID = & rpcID
106
-
107
103
// Set up the JSON-RPC connection.
108
104
client .c = jsonrpc .NewConn (conn , client .ll )
109
105
110
106
// Set up callbacks.
111
107
client .callbacks = make (map [string ]callback )
112
108
113
- // Set up echo loop statistics.
114
- var echoOK , echoFail int64
115
- client .echoOK = & echoOK
116
- client .echoFail = & echoFail
117
-
118
109
// Coordinates the sending of echo messages among multiple goroutines.
119
110
echoC := make (chan struct {})
120
111
@@ -155,7 +146,7 @@ func New(conn net.Conn, options ...OptionFunc) (*Client, error) {
155
146
func (c * Client ) requestID () string {
156
147
// We use integer IDs by convention, but OVSDB happily accepts
157
148
// 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 )
159
150
}
160
151
161
152
// Close closes a Client's connection and cleans up its resources.
@@ -174,8 +165,8 @@ func (c *Client) Stats() ClientStats {
174
165
s .Callbacks .Current = len (c .callbacks )
175
166
c .cbMu .RUnlock ()
176
167
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 ))
179
170
180
171
return s
181
172
}
@@ -361,11 +352,11 @@ func (c *Client) echoLoop(ctx context.Context, echoC <-chan struct{}) {
361
352
}
362
353
363
354
// Count other errors as failures.
364
- atomic .AddInt64 (c .echoFail , 1 )
355
+ atomic .AddInt64 (& c .echoFail , 1 )
365
356
continue
366
357
}
367
358
368
- atomic .AddInt64 (c .echoOK , 1 )
359
+ atomic .AddInt64 (& c .echoOK , 1 )
369
360
}
370
361
}
371
362
0 commit comments