Ensure sockets are deregistered on disconnect

This commit is contained in:
Tobie Morgan Hitchcock 2018-04-14 19:17:07 +01:00
parent 67cfca04b9
commit 677767d85b

View file

@ -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.