Skip to content

Commit

Permalink
Buffer ack receive chan (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wat authored May 30, 2020
1 parent 218a69c commit 88550ac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (c *BaseClient) Publish(ctx context.Context, message *Message) error {
chPubAck = make(chan *pktPubAck, 1)
c.sig.mu.Lock()
if c.sig.chPubAck == nil {
c.sig.chPubAck = make(map[uint16]chan *pktPubAck)
c.sig.chPubAck = make(map[uint16]chan *pktPubAck, 1)
}
c.sig.chPubAck[message.ID] = chPubAck
c.sig.mu.Unlock()
Expand All @@ -150,11 +150,11 @@ func (c *BaseClient) Publish(ctx context.Context, message *Message) error {
chPubComp = make(chan *pktPubComp, 1)
c.sig.mu.Lock()
if c.sig.chPubRec == nil {
c.sig.chPubRec = make(map[uint16]chan *pktPubRec)
c.sig.chPubRec = make(map[uint16]chan *pktPubRec, 1)
}
c.sig.chPubRec[message.ID] = chPubRec
if c.sig.chPubComp == nil {
c.sig.chPubComp = make(map[uint16]chan *pktPubComp)
c.sig.chPubComp = make(map[uint16]chan *pktPubComp, 1)
}
c.sig.chPubComp[message.ID] = chPubComp
c.sig.mu.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (c *BaseClient) Subscribe(ctx context.Context, subs ...Subscription) error
chSubAck := make(chan *pktSubAck, 1)
c.sig.mu.Lock()
if c.sig.chSubAck == nil {
c.sig.chSubAck = make(map[uint16]chan *pktSubAck)
c.sig.chSubAck = make(map[uint16]chan *pktSubAck, 1)
}
c.sig.chSubAck[id] = chSubAck
c.sig.mu.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion unsubscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (c *BaseClient) Unsubscribe(ctx context.Context, subs ...string) error {
chUnsubAck := make(chan *pktUnsubAck, 1)
c.sig.mu.Lock()
if c.sig.chUnsubAck == nil {
c.sig.chUnsubAck = make(map[uint16]chan *pktUnsubAck)
c.sig.chUnsubAck = make(map[uint16]chan *pktUnsubAck, 1)
}
c.sig.chUnsubAck[id] = chUnsubAck
c.sig.mu.Unlock()
Expand Down

0 comments on commit 88550ac

Please sign in to comment.