Skip to content

Commit

Permalink
Simplify shutdown logic a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
eapache committed Apr 27, 2015
1 parent 54eb5af commit 2bb62c1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions async_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ func (p *asyncProducer) Close() error {
}

func (p *asyncProducer) AsyncClose() {
go withRecover(func() {
p.input <- &ProducerMessage{flags: shutdown}
})
go withRecover(p.shutdown)
}

///////////////////////////////////////////
Expand All @@ -217,9 +215,7 @@ func (p *asyncProducer) topicDispatcher() {
}

if msg.flags&shutdown != 0 {
Logger.Println("Producer shutting down.")
shuttingDown = true
go withRecover(p.shutdown)
continue
} else if msg.retries == 0 {
if shuttingDown {
Expand Down Expand Up @@ -609,6 +605,9 @@ func (p *asyncProducer) retryHandler() {
// utility functions

func (p *asyncProducer) shutdown() {
Logger.Println("Producer shutting down.")
p.input <- &ProducerMessage{flags: shutdown}

p.inFlight.Wait()

if p.ownClient {
Expand Down

0 comments on commit 2bb62c1

Please sign in to comment.