feat(server): Differentiate between sessionCount and activeSessionCount

This commit is contained in:
Julius Pfrommer 2022-02-13 18:23:36 +01:00 committed by Julius Pfrommer
parent f31965a7e1
commit b98156aeb6
4 changed files with 10 additions and 6 deletions

View File

@ -526,8 +526,7 @@ UA_Server_getStatistics(UA_Server *server) {
stat.ns = server->networkStatistics;
stat.scs = server->secureChannelStatistics;
stat.ss.currentSessionCount =
server->serverDiagnosticsSummary.currentSessionCount;
stat.ss.currentSessionCount = server->activeSessionCount;
stat.ss.cumulatedSessionCount =
server->serverDiagnosticsSummary.cumulatedSessionCount;
stat.ss.securityRejectedSessionCount =

View File

@ -103,6 +103,7 @@ struct UA_Server {
/* Session Management */
LIST_HEAD(session_list, session_list_entry) sessions;
UA_UInt32 sessionCount;
UA_UInt32 activeSessionCount;
UA_Session adminSession; /* Local access to the services (for startup and
* maintenance) uses this Session with all possible
* access rights (Session Id: 1) */

View File

@ -516,6 +516,8 @@ readDiagnostics(UA_Server *server, const UA_NodeId *sessionId, void *sessionCont
switch(nodeId->identifier.numeric) {
case UA_NS0ID_SERVER_SERVERDIAGNOSTICS_SERVERDIAGNOSTICSSUMMARY:
server->serverDiagnosticsSummary.currentSessionCount =
server->activeSessionCount;
data = &server->serverDiagnosticsSummary;
type = &UA_TYPES[UA_TYPES_SERVERDIAGNOSTICSSUMMARYDATATYPE];
break;
@ -523,7 +525,7 @@ readDiagnostics(UA_Server *server, const UA_NodeId *sessionId, void *sessionCont
data = &server->serverDiagnosticsSummary.serverViewCount;
break;
case UA_NS0ID_SERVER_SERVERDIAGNOSTICS_SERVERDIAGNOSTICSSUMMARY_CURRENTSESSIONCOUNT:
data = &server->serverDiagnosticsSummary.currentSessionCount;
data = &server->activeSessionCount;
break;
case UA_NS0ID_SERVER_SERVERDIAGNOSTICS_SERVERDIAGNOSTICSSUMMARY_CUMULATEDSESSIONCOUNT:
data = &server->serverDiagnosticsSummary.cumulatedSessionCount;

View File

@ -57,13 +57,15 @@ UA_Server_removeSession(UA_Server *server, session_list_entry *sentry,
UA_Session_detachFromSecureChannel(session);
/* Deactivate the session */
sentry->session.activated = false;
if(sentry->session.activated) {
sentry->session.activated = false;
server->activeSessionCount--;
}
/* Detach the session from the session manager and make the capacity
* available */
LIST_REMOVE(sentry, pointers);
server->sessionCount--;
server->serverDiagnosticsSummary.currentSessionCount--;
switch(event) {
case UA_DIAGNOSTICEVENT_CLOSE:
@ -846,7 +848,7 @@ Service_ActivateSession(UA_Server *server, UA_SecureChannel *channel,
/* Activate the session */
if(!session->activated) {
session->activated = true;
server->serverDiagnosticsSummary.currentSessionCount++;
server->activeSessionCount++;
server->serverDiagnosticsSummary.cumulatedSessionCount++;
}