nomad: shrink the recv buffer of idle streams

This commit is contained in:
Armon Dadgar 2015-11-27 17:24:21 -08:00
parent 126e180657
commit 5ea5344773
1 changed files with 6 additions and 0 deletions

View File

@ -89,6 +89,12 @@ func (c *Conn) returnClient(client *StreamClient) {
if c.clients.Len() < c.pool.maxStreams && atomic.LoadInt32(&c.shouldClose) == 0 {
c.clients.PushFront(client)
didSave = true
// If this is a Yamux stream, shrink the internal buffers so that
// we can GC the idle memory
if ys, ok := client.stream.(*yamux.Stream); ok {
ys.Shrink()
}
}
c.clientLock.Unlock()
if !didSave {