diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-10-24 07:27:50 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-10-24 07:27:50 +0000 |
commit | 8ba0071e5073884b0b3092f033d5373d125dd3cf (patch) | |
tree | 30d17b2b0a0ec6315d519f07f02ccaf9a6f5ee06 /pkg/tcpip/network/fragmentation/reassembler.go | |
parent | 61c201cd8b4052a77e3ffbc78f68389a3893df45 (diff) | |
parent | 0a035a10115eca3f0c668b7fa20800db59586439 (diff) |
Merge release-20201019.0-56-g0a035a101 (automated)
Diffstat (limited to 'pkg/tcpip/network/fragmentation/reassembler.go')
-rw-r--r-- | pkg/tcpip/network/fragmentation/reassembler.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/pkg/tcpip/network/fragmentation/reassembler.go b/pkg/tcpip/network/fragmentation/reassembler.go index 9bb051a30..c0cc0bde0 100644 --- a/pkg/tcpip/network/fragmentation/reassembler.go +++ b/pkg/tcpip/network/fragmentation/reassembler.go @@ -41,6 +41,7 @@ type reassembler struct { heap fragHeap done bool creationTime int64 + callback func(bool) } func newReassembler(id FragmentID, clock tcpip.Clock) *reassembler { @@ -123,3 +124,24 @@ func (r *reassembler) checkDoneOrMark() bool { r.mu.Unlock() return prev } + +func (r *reassembler) setCallback(c func(bool)) bool { + r.mu.Lock() + defer r.mu.Unlock() + if r.callback != nil { + return false + } + r.callback = c + return true +} + +func (r *reassembler) release(timedOut bool) { + r.mu.Lock() + callback := r.callback + r.callback = nil + r.mu.Unlock() + + if callback != nil { + callback(timedOut) + } +} |