Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarter kickFlusher on subs #429

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,6 @@ func (nc *Conn) readLoop() {
nc.processOpErr(err)
break
}

if err := nc.parse(b[:n]); err != nil {
nc.processOpErr(err)
break
Expand Down Expand Up @@ -2775,7 +2774,6 @@ func (nc *Conn) subscribe(subj, queue string, cb MsgHandler, ch chan *Msg) (*Sub
nc.mu.Lock()
// ok here, but defer is generally expensive
defer nc.mu.Unlock()
defer nc.kickFlusher()

// Check for some error conditions.
if nc.isClosed() {
Expand Down Expand Up @@ -2812,10 +2810,15 @@ func (nc *Conn) subscribe(subj, queue string, cb MsgHandler, ch chan *Msg) (*Sub
nc.subsMu.Unlock()

// We will send these for all subs when we reconnect
// so that we can suppress here.
// so that we can suppress here if reconnecting.
if !nc.isReconnecting() {
fmt.Fprintf(nc.bw, subProto, subj, queue, sub.sid)
// Kick flusher if needed.
if len(nc.fch) == 0 {
nc.kickFlusher()
}
}

return sub, nil
}

Expand Down Expand Up @@ -3363,7 +3366,6 @@ func (nc *Conn) resendSubscriptions() {
if s.delivered < s.max {
adjustedMax = s.max - s.delivered
}

// adjustedMax could be 0 here if the number of delivered msgs
// reached the max, if so unsubscribe.
if adjustedMax == 0 {
Expand Down