浏览代码

Merge pull request #162 from PatrickDropbox/master

Fix race condition in producer's Close()
Evan Huus 11 年之前
父节点
当前提交
ab8518c05f
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      producer.go

+ 2 - 0
producer.go

@@ -110,6 +110,8 @@ func (p *Producer) Errors() chan error {
 // it may otherwise leak memory. You must call this before calling Close on the
 // it may otherwise leak memory. You must call this before calling Close on the
 // underlying client.
 // underlying client.
 func (p *Producer) Close() error {
 func (p *Producer) Close() error {
+	p.m.RLock()
+	defer p.m.RUnlock()
 	for _, bp := range p.brokerProducers {
 	for _, bp := range p.brokerProducers {
 		bp.Close()
 		bp.Close()
 	}
 	}