Skip to content

Commit

Permalink
Req receive timeout timer appears to leak.
Browse files Browse the repository at this point in the history
A lot of requests fired in succession potentially leave a lot
of timers running around in the background in the client.  This
should fix, although we should also (for performance reasons)
look at replacing the AfterFunc() semantic with a normal timer or
perhaps just using context.Context. (This code predates the existence
of Go standard contexts.)
  • Loading branch information
gdamore committed Mar 28, 2022
1 parent c629265 commit 6650d30
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions protocol/req/req.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 The Mangos Authors
// Copyright 2022 The Mangos Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use file except in compliance with the License.
Expand Down Expand Up @@ -159,6 +159,10 @@ func (p *pipe) receiver() {
c.resender.Stop()
c.resender = nil
}
if c.recvTimer != nil {
c.recvTimer.Stop()
c.recvTimer = nil
}
c.cond.Broadcast()
} else {
// No matching receiver so just drop it.
Expand Down Expand Up @@ -498,12 +502,12 @@ func (s *socket) OpenContext() (protocol.Context, error) {
return nil, protocol.ErrClosed
}
c := &context{
s: s,
cond: sync.NewCond(s),
bestEffort: s.defCtx.bestEffort,
resendTime: s.defCtx.resendTime,
sendExpire: s.defCtx.sendExpire,
recvExpire: s.defCtx.recvExpire,
s: s,
cond: sync.NewCond(s),
bestEffort: s.defCtx.bestEffort,
resendTime: s.defCtx.resendTime,
sendExpire: s.defCtx.sendExpire,
recvExpire: s.defCtx.recvExpire,
failNoPeers: s.defCtx.failNoPeers,
}
s.ctxs[c] = struct{}{}
Expand Down

0 comments on commit 6650d30

Please sign in to comment.