From 66092fc08bb642d1626387d126ca4bd2026d4657 Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Tue, 21 Mar 2023 14:17:44 +0100 Subject: [PATCH] Another try to fix a race condition --- cmd/dendrite-demo-pinecone/monolith/monolith.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/dendrite-demo-pinecone/monolith/monolith.go b/cmd/dendrite-demo-pinecone/monolith/monolith.go index e0776d95d..7f472e322 100644 --- a/cmd/dendrite-demo-pinecone/monolith/monolith.go +++ b/cmd/dendrite-demo-pinecone/monolith/monolith.go @@ -23,6 +23,7 @@ import ( "net" "net/http" "path/filepath" + "sync" "time" "github.com/gorilla/mux" @@ -79,6 +80,7 @@ type P2PMonolith struct { listener net.Listener httpListenAddr string stopHandlingEvents chan bool + startUpLock sync.Mutex } func GenerateDefaultConfig(sk ed25519.PrivateKey, storageDir string, cacheDir string, dbPrefix string) *config.Dendrite { @@ -296,6 +298,8 @@ func (p *P2PMonolith) setupHttpServers(userProvider *users.PineconeUserProvider, } func (p *P2PMonolith) startHTTPServers() { + p.startUpLock.Lock() + defer p.startUpLock.Unlock() go func() { // Build both ends of a HTTP multiplex. p.httpServer = &http.Server{