From 06a7453984adca0b34e62421a1baa8fe54b0d7bb Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Mon, 22 Jun 2020 22:00:23 +0200 Subject: [refactor] several simplifications after review - simplify notification routine (we dont need no rejected action). we just check every hour, as in the original code. - open links directly from Qt - rename some global variables to make them less cryptic - move cleanup function to the same module that created them --- pkg/backend/status.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'pkg/backend/status.go') diff --git a/pkg/backend/status.go b/pkg/backend/status.go index 2e9c282..2bfb52d 100644 --- a/pkg/backend/status.go +++ b/pkg/backend/status.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "log" + "sync" "0xacab.org/leap/bitmask-vpn/pkg/bitmask" "0xacab.org/leap/bitmask-vpn/pkg/config" @@ -17,6 +18,8 @@ const ( failedStr = "failed" ) +var statusMutex sync.Mutex + // ctx will be our glorious global object. // if we ever switch again to a provider-agnostic app, we should keep a map here. var ctx *connectionCtx @@ -42,8 +45,8 @@ type connectionCtx struct { } func (c connectionCtx) toJson() ([]byte, error) { - stmut.Lock() - defer stmut.Unlock() + statusMutex.Lock() + defer statusMutex.Unlock() b, err := json.Marshal(c) if err != nil { log.Println(err) @@ -69,8 +72,8 @@ func (c connectionCtx) updateStatus() { } func setStatus(st status) { - stmut.Lock() - defer stmut.Unlock() + statusMutex.Lock() + defer statusMutex.Unlock() ctx.Status = st go trigger(OnStatusChanged) } -- cgit v1.2.3