From 4cb196f50a28a9647945fdfdf884a47be60b7084 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Mon, 5 Sep 2016 19:39:16 +1000 Subject: [PATCH] server: Close store properly, on shutdown --- irc/server.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/irc/server.go b/irc/server.go index 5536060e..7d27b885 100644 --- a/irc/server.go +++ b/irc/server.go @@ -90,7 +90,6 @@ func NewServer(config *Config) *Server { if err != nil { log.Fatal(fmt.Sprintf("Failed to open datastore: %s", err.Error())) } - defer db.Close() server.store = *db // load password manager @@ -237,13 +236,16 @@ func (server *Server) loadChannels() { } func (server *Server) Shutdown() { - server.db.Close() + //TODO(dan): Make sure we disallow new nicks for _, client := range server.clients.byNick { client.Notice("Server is shutting down") } if err := server.db.Close(); err != nil { - Log.error.Println("Server.Shutdown: error:", err) + Log.error.Println("Server.Shutdown db.Close: error:", err) + } + if err := server.store.Close(); err != nil { + Log.error.Println("Server.Shutdown store.Close: error:", err) } }