diff --git a/server.go b/server.go index 9347304..85ba771 100644 --- a/server.go +++ b/server.go @@ -445,6 +445,10 @@ func (s *Server) handleRegisteredCommand(command string, args []string) { // response first. Once we get that, it'll connect instantly go func() { <-time.After(WAIT_FOR_VERSION * time.Second) + + s.ClientStateLock.Lock() + defer s.ClientStateLock.Unlock() + s.maybeStartUpstream() }() @@ -464,9 +468,6 @@ func (s *Server) handleRegisteredCommand(command string, args []string) { } func (s *Server) maybeStartUpstream() { - s.ClientStateLock.Lock() - defer s.ClientStateLock.Unlock() - if s.clientState != CSJoined { // Join for the first time s.clientState = CSJoined @@ -513,6 +514,9 @@ func (s *Server) SetClientSoftwareVersion(ver string) { s.upstreamLauncher.Self.ClientVersion = version s.recievedCtcpVersion = true + s.ClientStateLock.Lock() + defer s.ClientStateLock.Unlock() + if s.upstream != nil { s.upstream.Hco.Self.ClientTag = tag s.upstream.Hco.Self.ClientVersion = version @@ -520,6 +524,7 @@ func (s *Server) SetClientSoftwareVersion(ver string) { } else { // Connected for the first time (order was CTCP VERSION --> JOIN) + s.maybeStartUpstream() }