Don't leak writer and index goroutines on close
This commit is contained in:
parent
4a6b43bcae
commit
a720f90a70
|
@ -332,12 +332,17 @@ func (c *rawConnection) indexSerializerLoop() {
|
||||||
// large index update from the other side. But we must also ensure to
|
// large index update from the other side. But we must also ensure to
|
||||||
// process the indexes in the order they are received, hence the separate
|
// process the indexes in the order they are received, hence the separate
|
||||||
// routine and buffered channel.
|
// routine and buffered channel.
|
||||||
for ii := range incomingIndexes {
|
for {
|
||||||
|
select {
|
||||||
|
case ii := <-incomingIndexes:
|
||||||
if ii.update {
|
if ii.update {
|
||||||
c.receiver.IndexUpdate(ii.id, ii.repo, ii.files)
|
c.receiver.IndexUpdate(ii.id, ii.repo, ii.files)
|
||||||
} else {
|
} else {
|
||||||
c.receiver.Index(ii.id, ii.repo, ii.files)
|
c.receiver.Index(ii.id, ii.repo, ii.files)
|
||||||
}
|
}
|
||||||
|
case <-c.closed:
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,7 +455,9 @@ func (c *rawConnection) send(h header, es ...encodable) bool {
|
||||||
|
|
||||||
func (c *rawConnection) writerLoop() {
|
func (c *rawConnection) writerLoop() {
|
||||||
var err error
|
var err error
|
||||||
for es := range c.outbox {
|
for {
|
||||||
|
select {
|
||||||
|
case es := <-c.outbox:
|
||||||
for _, e := range es {
|
for _, e := range es {
|
||||||
e.encodeXDR(c.xw)
|
e.encodeXDR(c.xw)
|
||||||
}
|
}
|
||||||
|
@ -459,6 +466,9 @@ func (c *rawConnection) writerLoop() {
|
||||||
c.close(err)
|
c.close(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
case <-c.closed:
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue