|
@@ -4,12 +4,14 @@
|
|
|
|
|
|
UA_StatusCode
|
|
UA_StatusCode
|
|
UA_SessionManager_init(UA_SessionManager *sessionManager, UA_UInt32 maxSessionCount,
|
|
UA_SessionManager_init(UA_SessionManager *sessionManager, UA_UInt32 maxSessionCount,
|
|
- UA_UInt32 maxSessionLifeTime, UA_UInt32 startSessionId) {
|
|
|
|
|
|
+ UA_UInt32 maxSessionLifeTime, UA_UInt32 startSessionId,
|
|
|
|
+ UA_Logger logger) {
|
|
LIST_INIT(&sessionManager->sessions);
|
|
LIST_INIT(&sessionManager->sessions);
|
|
sessionManager->maxSessionCount = maxSessionCount;
|
|
sessionManager->maxSessionCount = maxSessionCount;
|
|
sessionManager->lastSessionId = startSessionId;
|
|
sessionManager->lastSessionId = startSessionId;
|
|
sessionManager->maxSessionLifeTime = maxSessionLifeTime;
|
|
sessionManager->maxSessionLifeTime = maxSessionLifeTime;
|
|
sessionManager->currentSessionCount = 0;
|
|
sessionManager->currentSessionCount = 0;
|
|
|
|
+ sessionManager->logger = logger;
|
|
return UA_STATUSCODE_GOOD;
|
|
return UA_STATUSCODE_GOOD;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -27,6 +29,8 @@ void UA_SessionManager_cleanupTimedOut(UA_SessionManager *sessionManager,
|
|
session_list_entry *sentry, *temp;
|
|
session_list_entry *sentry, *temp;
|
|
LIST_FOREACH_SAFE(sentry, &sessionManager->sessions, pointers, temp) {
|
|
LIST_FOREACH_SAFE(sentry, &sessionManager->sessions, pointers, temp) {
|
|
if(sentry->session.validTill < now) {
|
|
if(sentry->session.validTill < now) {
|
|
|
|
+ UA_LOG_DEBUG(sessionManager->logger, UA_LOGCATEGORY_SESSION, "Session with token %i has timed out and is removed",
|
|
|
|
+ sentry->session.sessionId.identifier.numeric);
|
|
LIST_REMOVE(sentry, pointers);
|
|
LIST_REMOVE(sentry, pointers);
|
|
UA_Session_deleteMembersCleanup(&sentry->session, server);
|
|
UA_Session_deleteMembersCleanup(&sentry->session, server);
|
|
UA_free(sentry);
|
|
UA_free(sentry);
|
|
@@ -40,11 +44,16 @@ UA_SessionManager_getSession(UA_SessionManager *sessionManager, const UA_NodeId
|
|
session_list_entry *current = NULL;
|
|
session_list_entry *current = NULL;
|
|
LIST_FOREACH(current, &sessionManager->sessions, pointers) {
|
|
LIST_FOREACH(current, &sessionManager->sessions, pointers) {
|
|
if(UA_NodeId_equal(¤t->session.authenticationToken, token)) {
|
|
if(UA_NodeId_equal(¤t->session.authenticationToken, token)) {
|
|
- if(UA_DateTime_now() > current->session.validTill)
|
|
|
|
|
|
+ if(UA_DateTime_now() > current->session.validTill) {
|
|
|
|
+ UA_LOG_DEBUG(sessionManager->logger, UA_LOGCATEGORY_SESSION, "Try to use Session with token %i, but has timed out",
|
|
|
|
+ token->identifier.numeric);
|
|
return NULL;
|
|
return NULL;
|
|
|
|
+ }
|
|
return ¤t->session;
|
|
return ¤t->session;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ UA_LOG_DEBUG(sessionManager->logger, UA_LOGCATEGORY_SESSION, "Try to use Session with token %i but is not found",
|
|
|
|
+ token->identifier.numeric);
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|