3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

don't buffer channels (except signal channel)

This commit is contained in:
Jeremy Latt 2014-03-08 14:20:36 -08:00
parent 4268c4a936
commit d1a299792e

View File

@ -16,6 +16,11 @@ import (
"time"
)
var (
SERVER_SIGNALS = []os.Signal{syscall.SIGINT, syscall.SIGHUP,
syscall.SIGTERM, syscall.SIGQUIT}
)
type Server struct {
channels ChannelNameMap
clients *ClientLookupSet
@ -36,15 +41,15 @@ func NewServer(config *Config) *Server {
server := &Server{
channels: make(ChannelNameMap),
clients: NewClientLookupSet(),
commands: make(chan Command, 16),
commands: make(chan Command),
ctime: time.Now(),
db: OpenDB(config.Server.Database),
idle: make(chan *Client, 16),
idle: make(chan *Client),
motdFile: config.Server.MOTD,
name: config.Server.Name,
newConns: make(chan net.Conn, 16),
newConns: make(chan net.Conn),
operators: config.Operators(),
signals: make(chan os.Signal, 1),
signals: make(chan os.Signal, len(SERVER_SIGNALS)),
whoWas: NewWhoWasList(100),
}
@ -58,8 +63,7 @@ func NewServer(config *Config) *Server {
go server.listen(addr)
}
signal.Notify(server.signals, syscall.SIGINT, syscall.SIGHUP,
syscall.SIGTERM, syscall.SIGQUIT)
signal.Notify(server.signals, SERVER_SIGNALS...)
return server
}