diff options
Diffstat (limited to 'rhimport')
-rw-r--r-- | rhimport/session_store.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/rhimport/session_store.go b/rhimport/session_store.go index f25a297..a511d52 100644 --- a/rhimport/session_store.go +++ b/rhimport/session_store.go @@ -29,6 +29,7 @@ import ( "encoding/base64" "fmt" "net/http" + "time" "code.helsinki.at/rhrd-go/rddb" ) @@ -261,12 +262,26 @@ func (store *SessionStore) remove(username, id string) (resp removeSessionRespon return } +func (store *SessionStore) maintenanceTask() { + for name, user := range store.store { + user.callUpdateHandler(nil, nil) + if len(user.sessions) == 0 && len(user.updateCBs) == 0 { + delete(store.store, name) + rhdl.Printf("SessionStore: removed user '%s'", name) + } + } +} + func (store *SessionStore) dispatchRequests() { defer func() { store.done <- true }() + + mt := time.NewTicker(1 * time.Minute) for { select { case <-store.quit: return + case <-mt.C: + store.maintenanceTask() case req := <-store.newChan: req.response <- store.new(req.ctx, req.refId) case req := <-store.getChan: |