Explorar o código

Fix race condition in Close()

Patrick Lee %!s(int64=11) %!d(string=hai) anos
pai
achega
fbee6d3a0c
Modificáronse 1 ficheiros con 2 adicións e 0 borrados
  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
 // underlying client.
 func (p *Producer) Close() error {
+	p.m.Lock()
+	defer p.m.Unlock()
 	for _, bp := range p.brokerProducers {
 		bp.Close()
 	}