summaryrefslogtreecommitdiffstats
path: root/src/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/session.c')
-rw-r--r--src/session.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/session.c b/src/session.c
index 22e50cfc..320eab9b 100644
--- a/src/session.c
+++ b/src/session.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 "IoT.bzh"
+ * Copyright (C) 2015, 2016 "IoT.bzh"
* Author "Fulup Ar Foll"
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -197,11 +197,10 @@ static void ctxStoreCleanUp (time_t now)
// Loop on Sessions Table and remove anything that is older than timeout
for (idx=0; idx < sessions.max; idx++) {
- ctx = ctxClientAddRef(sessions.store[idx]);
+ ctx = sessions.store[idx];
if (ctx != NULL && ctxStoreTooOld(ctx, now)) {
ctxClientClose (ctx);
}
- ctxClientUnref(ctx);
}
}
@@ -291,6 +290,10 @@ void ctxClientClose (struct AFB_clientCtx *clientCtx)
ctxUuidFreeCB (clientCtx);
while(clientCtx->listeners != NULL)
ctxClientEventListenerRemove(clientCtx, clientCtx->listeners->listener);
+ if (clientCtx->refcount == 0) {
+ ctxStoreDel (clientCtx);
+ free(clientCtx);
+ }
}
}