init ephemeralService right away in service cache to avoid potential segfaults
This commit is contained in:
parent
069c754595
commit
42e04c17c3
|
@ -339,7 +339,7 @@ func (e *engine) peerWithTokenServer(onion string, tokenServerOnion string, toke
|
|||
// Otherwise...let's reconnect
|
||||
}
|
||||
|
||||
connectionService = &connectionLockedService{}
|
||||
connectionService = &connectionLockedService{service: new(tor.BaseOnionService)}
|
||||
e.ephemeralServices[onion] = connectionService
|
||||
|
||||
connectionService.connectingLock.Lock()
|
||||
|
@ -349,20 +349,16 @@ func (e *engine) peerWithTokenServer(onion string, tokenServerOnion string, toke
|
|||
log.Debugf("Peering with Token Server %v %v", onion, tokenServerOnion)
|
||||
e.ignoreOnShutdown(e.serverConnecting)(onion)
|
||||
// Create a new ephemeral service for this connection
|
||||
ephemeralService := new(tor.BaseOnionService)
|
||||
eid, epk := primitives.InitializeEphemeralIdentity()
|
||||
ephemeralService.Init(e.acn, epk, &eid)
|
||||
connectionService.service.Init(e.acn, epk, &eid)
|
||||
|
||||
Y := ristretto255.NewElement()
|
||||
Y.UnmarshalText([]byte(tokenServerY))
|
||||
connected, err := ephemeralService.Connect(onion, NewTokenBoardClient(e.acn, Y, tokenServerOnion, lastKnownSignature, e.receiveGroupMessage, e.serverAuthed, e.serverSynced, e.ignoreOnShutdown(e.serverDisconnected)))
|
||||
e.ephemeralServicesLock.Lock()
|
||||
e.ephemeralServices[onion].service = ephemeralService
|
||||
e.ephemeralServicesLock.Unlock()
|
||||
connected, err := connectionService.service.Connect(onion, NewTokenBoardClient(e.acn, Y, tokenServerOnion, lastKnownSignature, e.receiveGroupMessage, e.serverAuthed, e.serverSynced, e.ignoreOnShutdown(e.serverDisconnected)))
|
||||
// If we are already connected...check if we are authed and issue an auth event
|
||||
// (This allows the ui to be stateless)
|
||||
if connected && err != nil {
|
||||
conn, err := ephemeralService.GetConnection(onion)
|
||||
conn, err := connectionService.service.GetConnection(onion)
|
||||
if err == nil {
|
||||
|
||||
// If the server is synced, resend the synced status update
|
||||
|
|
Loading…
Reference in New Issue