-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
hi, my English is not very good, but I try to describe it as clearly as possible.
I think the “conn = p.newConnection(k, s, ts)” should be placed after checking conn2. If Conn2 is not nil and Conn is taken out but not put into Streampool.conns, it will not be flushed by assembler.FlushOlderThan, and it will not be garbage collected and leak memory due to the addition of put it into streampool.all
Please forgive me if I am wrong.
func (p *StreamPool) getConnection(k key, end bool, ts time.Time) *connection {
p.mu.RLock()
conn := p.conns[k]
p.mu.RUnlock()
if end || conn != nil {
return conn
}
s := p.factory.New(k[0], k[1])
p.mu.Lock()
conn = p.newConnection(k, s, ts) //if conn2 is not nil, I think it will memory leak.
if conn2 := p.conns[k]; conn2 != nil {
p.mu.Unlock()
return conn2
}
p.conns[k] = conn
p.mu.Unlock()
return conn
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels