From bdb4b93f59b500a2c84dd729ebfe0636677d710a Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Sun, 4 Dec 2022 20:08:41 -0800 Subject: [PATCH] make ActivatePeerEngine safe to recall --- app/app.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/app.go b/app/app.go index 734db56..92ae38a 100644 --- a/app/app.go +++ b/app/app.go @@ -282,13 +282,16 @@ func (app *application) ActivateEngines(doListen, doPeers, doServers bool) { func (app *application) ActivatePeerEngine(onion string, doListen, doPeers, doServers bool) { profile := app.GetPeer(onion) if profile != nil { - app.engines[profile.GetOnion()], _ = profile.GenerateProtocolEngine(app.acn, app.eventBuses[profile.GetOnion()]) - app.eventBuses[profile.GetOnion()].Publish(event.NewEventList(event.ProtocolEngineCreated)) - app.QueryACNStatus() - if doListen { - profile.Listen() + if _, exists := app.engines[onion]; !exists { + app.engines[profile.GetOnion()], _ = profile.GenerateProtocolEngine(app.acn, app.eventBuses[profile.GetOnion()]) + + app.eventBuses[profile.GetOnion()].Publish(event.NewEventList(event.ProtocolEngineCreated)) + app.QueryACNStatus() + if doListen { + profile.Listen() + } + profile.StartConnections(doPeers, doServers) } - profile.StartConnections(doPeers, doServers) } }