Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #38 from uber/replicator_busy_loop
Browse files Browse the repository at this point in the history
fix a busy loop in replicator which is causing high CPU usage
  • Loading branch information
datoug committed Jan 25, 2017
2 parents f21e38f + b64347c commit 026daaa
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions services/replicator/inconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ func (conn *inConnection) writeMsgsStream() {
return
}
} else {
// Note: we check closeChannel only in the default case.
// This makes sure if the connection is closed, we'll still try to read messages from msgCh
// and write to stream
select {
case msg := <-conn.msgCh:
if err := conn.stream.Write(msg); err != nil {
Expand All @@ -175,14 +172,8 @@ func (conn *inConnection) writeMsgsStream() {
conn.logger.Error(`flush msg failed`)
go conn.close()
}

default:
select {
case <-conn.closeChannel:
return
default:
break
}
case <-conn.closeChannel:
return
}
}
}
Expand Down

0 comments on commit 026daaa

Please sign in to comment.