Fix Race Condition

This commit is contained in:
Sarah Jamie Lewis 2023-05-02 13:45:19 -07:00
parent f5c397876b
commit 2abfaf82a1
1 changed files with 2 additions and 0 deletions

View File

@ -160,6 +160,8 @@ func (app *application) ListProfiles() []string {
// GetPeer returns a cwtchPeer for a given onion address
func (app *application) GetPeer(onion string) peer.CwtchPeer {
app.appmutex.Lock()
defer app.appmutex.Unlock()
if profile, ok := app.peers[onion]; ok {
return profile
}