Skip to content

Commit

Permalink
Merge pull request #243 from jehiah/is_starved_243
Browse files Browse the repository at this point in the history
limit reader.IsStarved() to active connections
  • Loading branch information
mreiferson committed Aug 6, 2013
2 parents 902cfb4 + 13665ab commit 1154c59
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nsq/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ func (q *Reader) IsStarved() bool {

for _, conn := range q.nsqConnections {
threshold := int64(float64(atomic.LoadInt64(&conn.lastRdyCount)) * 0.85)
if atomic.LoadInt64(&conn.messagesInFlight) >= threshold &&
atomic.LoadInt32(&conn.stopFlag) != 1 {
inFlight := atomic.LoadInt64(&conn.messagesInFlight)
if inFlight >= threshold && inFlight > 0 && atomic.LoadInt32(&conn.stopFlag) != 1 {
return true
}
}
Expand Down

0 comments on commit 1154c59

Please sign in to comment.