move mutex calls to outer function

--HG--
branch : nmdc-ircfrontend
This commit is contained in:
. 2016-05-09 18:49:00 +12:00
parent 7bf832322d
commit 74e4f6cfa3

View File

@ -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()
}