+/* unlock the set of sessions of exclusive access */
+static inline void sessionset_unlock()
+{
+ pthread_mutex_unlock(&sessions.mutex);
+}
+
+/*
+ * search within the set of sessions the session of 'uuid'.
+ * 'hashidx' is the precomputed hash for 'uuid'
+ * return the session or NULL
+ */
+static struct afb_session *sessionset_search(const char *uuid, uint8_t hashidx)
+{
+ struct afb_session *session;
+
+ session = sessions.heads[hashidx];
+ while (session && strcmp(uuid, session->uuid))
+ session = session->next;
+
+ return session;
+}
+
+/* add 'session' to the set of sessions */
+static int sessionset_add(struct afb_session *session, uint8_t hashidx)
+{
+ /* check availability */
+ if (sessions.max && sessions.count >= sessions.max) {
+ errno = EBUSY;
+ return -1;
+ }
+
+ /* add the session */
+ session->next = sessions.heads[hashidx];
+ sessions.heads[hashidx] = session;
+ sessions.count++;
+ return 0;
+}
+
+/* make a new uuid not used in the set of sessions */
+static uint8_t sessionset_make_uuid (uuid_stringz_t uuid)
+{
+ uint8_t hashidx;
+
+ do {
+ uuid_new_stringz(uuid);
+ hashidx = pearson4(uuid);
+ } while(sessionset_search(uuid, hashidx));
+ return hashidx;
+}
+
+/* lock the 'session' for exclusive access */
+static inline void session_lock(struct afb_session *session)