+static void record_session(struct afb_stub_ws *stubws, struct afb_session *session)
+{
+ struct server_session *s, **prv;
+
+ /* search */
+ prv = &stubws->sessions;
+ while ((s = *prv)) {
+ if (s->session == session)
+ return;
+ if (afb_session_is_closed(s->session)) {
+ *prv = s->next;
+ afb_session_unref(s->session);
+ free(s);
+ }
+ else
+ prv = &s->next;
+ }
+
+ /* create */
+ s = malloc(sizeof *s);
+ if (s) {
+ s->session = afb_session_addref(session);
+ s->next = stubws->sessions;
+ stubws->sessions = s;
+ }
+}
+
+static void release_sessions(struct afb_stub_ws *stubws)
+{
+ struct server_session *s;
+
+ while((s = stubws->sessions)) {
+ stubws->sessions = s->next;
+ afb_session_unref(s->session);
+ free(s);
+ }
+}
+
+/*****************************************************/
+