server session CHANGE option to free all session in a pollsession structure
diff --git a/src/session_server.c b/src/session_server.c
index 8ad2c5a..7f7ce65 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -793,7 +793,7 @@
}
API void
-nc_ps_clear(struct nc_pollsession *ps)
+nc_ps_clear(struct nc_pollsession *ps, int all)
{
uint16_t i;
struct nc_session *session;
@@ -804,7 +804,7 @@
}
for (i = 0; i < ps->session_count; ) {
- if (ps->sessions[i]->status != NC_STATUS_RUNNING) {
+ if (all || (ps->sessions[i]->status != NC_STATUS_RUNNING)) {
session = ps->sessions[i];
nc_ps_del_session(ps, session);
nc_session_free(session);
diff --git a/src/session_server.h b/src/session_server.h
index e1cb75f..d70202c 100644
--- a/src/session_server.h
+++ b/src/session_server.h
@@ -192,14 +192,15 @@
int nc_ps_poll(struct nc_pollsession *ps, int timeout);
/**
- * @brief Remove invalid sessions from a pollsession structure and
- * call #nc_session_free() on them.
+ * @brief Remove sessions from a pollsession structure and
+ * call nc_session_free() on them.
*
- * Calling this function makes sense if nc_ps_poll() returned 3.
+ * Calling this function with \p all false makes sense if nc_ps_poll() returned 3.
*
* @param[in] ps Pollsession structure to clear.
+ * @param[in] all Whether to free all sessions, or only the invalid ones.
*/
-void nc_ps_clear(struct nc_pollsession *ps);
+void nc_ps_clear(struct nc_pollsession *ps, int all);
#if defined(NC_ENABLED_SSH) || defined(NC_ENABLED_TLS)