diff --git a/lib.go b/lib.go index 5727865..291c991 100644 --- a/lib.go +++ b/lib.go @@ -10,17 +10,15 @@ import ( "cwtch.im/cwtch/model" "cwtch.im/cwtch/model/attr" "cwtch.im/cwtch/peer" - contact "git.openprivacy.ca/flutter/libcwtch-go/features/contacts" - "git.openprivacy.ca/flutter/libcwtch-go/features/groups" - "git.openprivacy.ca/openprivacy/connectivity" - "runtime" - "strings" - "sync" - "encoding/json" "fmt" "git.openprivacy.ca/flutter/libcwtch-go/constants" + contact "git.openprivacy.ca/flutter/libcwtch-go/features/contacts" + "git.openprivacy.ca/flutter/libcwtch-go/features/groups" "git.openprivacy.ca/flutter/libcwtch-go/utils" + "git.openprivacy.ca/openprivacy/connectivity" + "runtime" + "strings" "encoding/base64" "git.openprivacy.ca/openprivacy/connectivity/tor" @@ -43,7 +41,6 @@ var eventHandler *utils.EventHandler var acnQueue event.Queue var contactEventsQueue event.Queue var globalACN connectivity.ACN -var startLock sync.Mutex // ChatMessage API currently not officially documented, see // https://git.openprivacy.ca/cwtch.im/secure-development-handbook/issues/3 @@ -89,8 +86,6 @@ func StartCwtch(appDir string, torPath string) int { } func _startCwtch(appDir string, torPath string) { - startLock.Lock() - defer startLock.Unlock() // Exclude Tapir wire Messages (We need a TRACE level) log.ExcludeFromPattern("service.go") @@ -165,8 +160,10 @@ func c_ReconnectCwtchForeground() { // Like StartCwtch, but StartCwtch has already been called so we don't need to restart Tor etc (probably) // Do need to re-send initial state tho, eg profiles that are already loaded func ReconnectCwtchForeground() { - startLock.Lock() - defer startLock.Unlock() + if application == nil { + log.Errorf("ReconnectCwtchForeground: Application is nil, presuming stale thread, EXITING Reconnect\n") + return + } peerList := application.ListPeers() for onion := range peerList { eventHandler.Push(event.NewEvent(event.NewPeer, map[event.Field]string{event.Identity: onion, event.Created: event.False}))