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
*/
struct afb_session *afb_session_addref(struct afb_session *session)
{
if (session != NULL) {
- afb_hook_session_unref(session);
afb_hook_session_addref(session);
session->refcount++;
session_unlock(session);
session_lock(session);
afb_hook_session_unref(session);
- if (!--session->refcount) {
+ if (--session->refcount) {
if (session->autoclose)
session_close(session);
if (session->notinset) {