Skip to content
Snippets Groups Projects
Commit 5f65e390 authored by André Luiz dos Santos's avatar André Luiz dos Santos
Browse files

Unexport Client.Mutex

parent 5aea8396
Branches
No related tags found
No related merge requests found
......@@ -12,8 +12,8 @@ type replyCloser interface {
// Async starts asynchronous mode and returns immediately.
func (c *Client) Async() <-chan error {
c.Lock()
defer c.Unlock()
c.mu.Lock()
defer c.mu.Unlock()
errC := make(chan error, 1)
if c.async {
......@@ -45,26 +45,26 @@ func (c *Client) asyncLoop() error {
return err
}
c.Lock()
c.mu.Lock()
r, ok := c.tags[sen.Tag]
c.Unlock()
c.mu.Unlock()
if !ok {
continue
}
done, err := r.processSentence(sen)
if done || err != nil {
c.Lock()
c.mu.Lock()
delete(c.tags, sen.Tag)
c.Unlock()
c.mu.Unlock()
closeReply(r, err)
}
}
}
func (c *Client) closeTags(err error) {
c.Lock()
defer c.Unlock()
c.mu.Lock()
defer c.mu.Unlock()
for _, r := range c.tags {
closeReply(r, err)
......
......@@ -27,7 +27,7 @@ type Client struct {
async bool
nextTag int64
tags map[string]sentenceProcessor
sync.Mutex
mu sync.Mutex
}
// NewClient returns a new Client over rwc. Login must be called.
......
......@@ -53,8 +53,8 @@ func (c *Client) ListenArgsQueue(sentence []string, queueSize int) (*ListenReply
}
c.w.WriteWord(".tag=" + l.tag)
c.Lock()
defer c.Unlock()
c.mu.Lock()
defer c.mu.Unlock()
err := c.w.EndSentence()
if err != nil {
......
......@@ -49,8 +49,8 @@ func (c *Client) endCommandAsync() (*asyncReply, error) {
a.tag = fmt.Sprintf("r%d", c.nextTag)
c.w.WriteWord(".tag=" + a.tag)
c.Lock()
defer c.Unlock()
c.mu.Lock()
defer c.mu.Unlock()
err := c.w.EndSentence()
if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment