-static struct afb_session *add_session (const char *uuid, int timeout, time_t now, int idx)
+/* destroy the 'session' */
+static void session_destroy (struct afb_session *session)
+{
+#if WITH_AFB_HOOK
+ afb_hook_session_destroy(session);
+#endif
+ pthread_mutex_destroy(&session->mutex);
+ free(session->lang);
+ free(session);
+}
+
+/* update expiration of 'session' according to 'now' */
+static void session_update_expiration(struct afb_session *session, time_t now)
+{
+ time_t expiration;
+
+ /* compute expiration */
+ expiration = now + afb_session_timeout(session);
+ if (expiration < 0)
+ expiration = MAX_EXPIRATION;
+
+ /* record the expiration */
+ session->expiration = expiration;
+}
+
+/*
+ * Add a new session with the 'uuid' (of 'hashidx')
+ * and the 'timeout' starting from 'now'.
+ * Add it to the set of sessions
+ * Return the created session
+ */
+static struct afb_session *session_add(const char *uuid, int timeout, time_t now, uint8_t hashidx)