Improve Server.Handle readability
This commit is contained in:
parent
1df1ccf91e
commit
53017a7a5c
16
server.go
16
server.go
@ -455,26 +455,32 @@ func (s *Server) Handle(ic ircConn) {
|
|||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
|
|
||||||
s.metrics.downstreams.Add(1)
|
s.metrics.downstreams.Add(1)
|
||||||
|
defer s.metrics.downstreams.Add(-1)
|
||||||
|
|
||||||
id := atomic.AddUint64(&lastDownstreamID, 1)
|
id := atomic.AddUint64(&lastDownstreamID, 1)
|
||||||
dc := newDownstreamConn(s, ic, id)
|
dc := newDownstreamConn(s, ic, id)
|
||||||
|
defer dc.Close()
|
||||||
|
|
||||||
if shutdown {
|
if shutdown {
|
||||||
dc.SendMessage(&irc.Message{
|
dc.SendMessage(&irc.Message{
|
||||||
Command: "ERROR",
|
Command: "ERROR",
|
||||||
Params: []string{"Server is shutting down"},
|
Params: []string{"Server is shutting down"},
|
||||||
})
|
})
|
||||||
} else if err := dc.runUntilRegistered(); err != nil {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := dc.runUntilRegistered(); err != nil {
|
||||||
if !errors.Is(err, io.EOF) {
|
if !errors.Is(err, io.EOF) {
|
||||||
dc.logger.Printf("%v", err)
|
dc.logger.Printf("%v", err)
|
||||||
}
|
}
|
||||||
} else {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
dc.user.events <- eventDownstreamConnected{dc}
|
dc.user.events <- eventDownstreamConnected{dc}
|
||||||
if err := dc.readMessages(dc.user.events); err != nil {
|
if err := dc.readMessages(dc.user.events); err != nil {
|
||||||
dc.logger.Printf("%v", err)
|
dc.logger.Printf("%v", err)
|
||||||
}
|
}
|
||||||
dc.user.events <- eventDownstreamDisconnected{dc}
|
dc.user.events <- eventDownstreamDisconnected{dc}
|
||||||
}
|
|
||||||
dc.Close()
|
|
||||||
s.metrics.downstreams.Add(-1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) HandleAdmin(ic ircConn) {
|
func (s *Server) HandleAdmin(ic ircConn) {
|
||||||
|
Loading…
Reference in New Issue
Block a user