mirror of
https://github.com/minio/minio.git
synced 2025-03-28 08:20:58 -04:00
Fix mux client memory leak (#18956)
Add missing client cancellation, resulting in memory buildup tracing back to context.WithCancelCause/context.WithCancelDeadlineCause
This commit is contained in:
parent
ff80cfd83d
commit
63bf5f42a1
@ -287,6 +287,7 @@ func (c *Connection) newMuxClient(ctx context.Context) (*muxClient, error) {
|
|||||||
if dl, ok := ctx.Deadline(); ok {
|
if dl, ok := ctx.Deadline(); ok {
|
||||||
client.deadline = getDeadline(time.Until(dl))
|
client.deadline = getDeadline(time.Until(dl))
|
||||||
if client.deadline == 0 {
|
if client.deadline == 0 {
|
||||||
|
client.cancelFn(context.DeadlineExceeded)
|
||||||
return nil, context.DeadlineExceeded
|
return nil, context.DeadlineExceeded
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,6 +334,7 @@ func (c *Connection) Request(ctx context.Context, h HandlerID, req []byte) ([]by
|
|||||||
_, ok := c.outgoing.Load(client.MuxID)
|
_, ok := c.outgoing.Load(client.MuxID)
|
||||||
fmt.Println(client.MuxID, c.String(), "Connection.Request: DELETING MUX. Exists:", ok)
|
fmt.Println(client.MuxID, c.String(), "Connection.Request: DELETING MUX. Exists:", ok)
|
||||||
}
|
}
|
||||||
|
client.cancelFn(context.Canceled)
|
||||||
c.outgoing.Delete(client.MuxID)
|
c.outgoing.Delete(client.MuxID)
|
||||||
}()
|
}()
|
||||||
return client.traceRoundtrip(ctx, c.trace, h, req)
|
return client.traceRoundtrip(ctx, c.trace, h, req)
|
||||||
|
@ -63,10 +63,11 @@ func (s *Stream) Send(b []byte) error {
|
|||||||
func (s *Stream) Results(next func(b []byte) error) (err error) {
|
func (s *Stream) Results(next func(b []byte) error) (err error) {
|
||||||
done := false
|
done := false
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if s.cancel != nil {
|
||||||
|
s.cancel(err)
|
||||||
|
}
|
||||||
|
|
||||||
if !done {
|
if !done {
|
||||||
if s.cancel != nil {
|
|
||||||
s.cancel(err)
|
|
||||||
}
|
|
||||||
// Drain channel.
|
// Drain channel.
|
||||||
for range s.responses {
|
for range s.responses {
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user