Skip to content

Commit

Permalink
Fixed further race conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
林志宇 committed May 10, 2019
1 parent 45110a5 commit 218ab47
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 1 addition & 1 deletion internal/httpauth/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (c *Client) SetNonce(n Nonce) {
}

func (c *Client) getCurrentNonce() Nonce {
return Nonce(c.nonce)
return Nonce(atomic.LoadUint64(&c.nonce))
}

func (c *Client) incrementNonce() {
Expand Down
4 changes: 0 additions & 4 deletions pkg/messaging/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ func DefaultLinkConfig() *LinkConfig {
// Link represents a messaging connection in the perspective of an instance.
type Link struct {
rw io.ReadWriteCloser
rMx sync.Mutex
wMx sync.Mutex
config *LinkConfig
callbacks *Callbacks
}
Expand Down Expand Up @@ -174,9 +172,7 @@ func (c *Link) handleData(payload Frame, n int, err error) error {

func (c *Link) writeFrame(t FrameType, body []byte) (int, error) {
payload := MakeFrame(t, body)
c.wMx.Lock()
n, err := WriteFrame(c.rw, payload)
c.wMx.Unlock()
if err != nil {
return 0, err
}
Expand Down

0 comments on commit 218ab47

Please sign in to comment.