summaryrefslogtreecommitdiffstats
path: root/src/afb-session.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/afb-session.c')
-rw-r--r--src/afb-session.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/afb-session.c b/src/afb-session.c
index c23d414b..17ca7af8 100644
--- a/src/afb-session.c
+++ b/src/afb-session.c
@@ -347,6 +347,28 @@ int afb_session_init (int max_session_count, int timeout, const char *initok)
}
/**
+ * Iterate the sessions and call 'callback' with
+ * the 'closure' for each session.
+ */
+void afb_session_foreach(void (*callback)(void *closure, struct afb_session *session), void *closure)
+{
+ struct afb_session *session;
+ int idx;
+
+ /* Loop on Sessions Table and remove anything that is older than timeout */
+ sessionset_lock();
+ for (idx = 0 ; idx < HEADCOUNT; idx++) {
+ session = sessions.heads[idx];
+ while (session) {
+ if (!session->closed)
+ callback(closure, session);
+ session = session->next;
+ }
+ }
+ sessionset_unlock();
+}
+
+/**
* Cleanup the sessionset of its closed or expired sessions
*/
void afb_session_purge()