From 677767d85b888157a6b00a062a187eb92442721a Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sat, 14 Apr 2018 19:17:07 +0100 Subject: [PATCH] Ensure sockets are deregistered on disconnect --- db/db.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/db/db.go b/db/db.go index 4f761961..fd22aa46 100644 --- a/db/db.go +++ b/db/db.go @@ -53,15 +53,25 @@ type Dispatch struct { // Setup sets up the connection with the data layer func Setup(opts *cnf.Options) (err error) { + log.WithPrefix("db").Infof("Starting database") + db, err = kvs.New(opts) + return } // Exit shuts down the connection with the data layer -func Exit() error { +func Exit() (err error) { + log.WithPrefix("db").Infof("Gracefully shutting down database") + + for id, so := range sockets { + deregister(so.fibre, id)() + } + return db.Close() + } // Import loads database operations from a reader.