X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-session.c;h=17ca7af81be03a2058e114054de58ad8952bbea4;hb=5fccb2dcb97fac7fbc16d66e947477e41d30a2b4;hp=c23d414bc14b478509006d4097f4f27e554d2faa;hpb=f6a6c26058c8b6ca7500c84ffe13ca2b2dc8b49e;p=src%2Fapp-framework-binder.git 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 @@ -346,6 +346,28 @@ int afb_session_init (int max_session_count, int timeout, const char *initok) return 0; } +/** + * 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 */