3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-29 15:40:02 +01:00

bind to listening sockets before asyncing

This commit is contained in:
Jeremy Latt 2014-03-13 17:19:39 -07:00
parent 5df8173df2
commit 7db4347419

View File

@ -70,7 +70,7 @@ func NewServer(config *Config) *Server {
server.loadChannels() server.loadChannels()
for _, addr := range config.Server.Listen { for _, addr := range config.Server.Listen {
go server.listen(addr) server.listen(addr)
} }
signal.Notify(server.signals, SERVER_SIGNALS...) signal.Notify(server.signals, SERVER_SIGNALS...)
@ -189,6 +189,7 @@ func (s *Server) listen(addr string) {
Log.info.Printf("%s listening on %s", s, addr) Log.info.Printf("%s listening on %s", s, addr)
go func() {
for { for {
conn, err := listener.Accept() conn, err := listener.Accept()
if err != nil { if err != nil {
@ -199,6 +200,7 @@ func (s *Server) listen(addr string) {
s.newConns <- conn s.newConns <- conn
} }
}()
} }
// //