From b9e151b365061b4274c9a407e252060cb3fe5002 Mon Sep 17 00:00:00 2001 From: Taras Halturin Date: Wed, 30 Jun 2021 16:36:22 +0200 Subject: [PATCH] Fixcontextleaks (#53) * fix Context leaks * move versiong into the separated file * bump version --- node.go | 4 ---- process.go | 1 + registrar.go | 2 ++ version.go | 7 +++++++ 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 version.go diff --git a/node.go b/node.go index 2d0596c5..bd663048 100644 --- a/node.go +++ b/node.go @@ -83,10 +83,6 @@ const ( defaultRecvQueueLength int = 100 defaultFragmentationUnit = 65000 - versionOTP int = 22 - versionERTSprefix = "ergo" - version = "1.1.0" - // TLSmodeDisabled no TLS encryption TLSmodeDisabled TLSmodeType = "" // TLSmodeAuto generate self-signed certificate diff --git a/process.go b/process.go index ea69b0b3..240792dc 100644 --- a/process.go +++ b/process.go @@ -206,6 +206,7 @@ func (p *Process) SendAfter(to interface{}, message etf.Term, after time.Duratio // to prevent of timer leaks due to its not GCed until the timer fires timer := time.NewTimer(after) defer timer.Stop() + defer cancel() select { case <-ctx.Done(): diff --git a/registrar.go b/registrar.go index 61ae8a2b..c01af225 100644 --- a/registrar.go +++ b/registrar.go @@ -175,6 +175,8 @@ func (r *registrar) UnregisterProcess(pid etf.Pid) { } } r.mutexProcesses.Unlock() + // invoke cancel context to prevent memory leaks + p.Kill() return } r.mutexProcesses.Unlock() diff --git a/version.go b/version.go new file mode 100644 index 00000000..b6fda8f2 --- /dev/null +++ b/version.go @@ -0,0 +1,7 @@ +package ergo + +const ( + versionOTP int = 22 + versionERTSprefix = "ergo" + version = "1.2.4" +)