Selaa lähdekoodia

*adding a safety check for cleaning up client, *adding a really random session id to prevent collisions #366

Stasik0 9 vuotta sitten
vanhempi
commit
3e6b52069e
2 muutettua tiedostoa jossa 3 lisäystä ja 2 poistoa
  1. 2 1
      examples/networklayer_tcp.c
  2. 1 1
      src/server/ua_session_manager.c

+ 2 - 1
examples/networklayer_tcp.c

@@ -465,7 +465,8 @@ static void ClientNetworkLayerReleaseBuffer(UA_Connection *connection, UA_ByteSt
 
 static void ClientNetworkLayerClose(UA_Connection *connection) {
 #ifndef UA_MULTITHREADING
-    UA_ByteString_delete(connection->handle);
+    if(connection->handle)
+        UA_ByteString_delete(connection->handle);
     connection->handle = NULL;
 #endif
     if(connection->state == UA_CONNECTION_CLOSED)

+ 1 - 1
src/server/ua_session_manager.c

@@ -61,7 +61,7 @@ UA_StatusCode UA_SessionManager_createSession(UA_SessionManager *sessionManager,
     sessionManager->currentSessionCount++;
     UA_Session_init(&newentry->session);
     newentry->session.sessionId = UA_NODEID_NUMERIC(1, sessionManager->lastSessionId++);
-    UA_UInt32 randSeed = sessionManager->lastSessionId;
+    UA_UInt32 randSeed = sessionManager->lastSessionId + UA_DateTime_now();
     newentry->session.authenticationToken = UA_NODEID_GUID(1, UA_Guid_random(&randSeed));
     if(request->requestedSessionTimeout <= sessionManager->maxSessionLifeTime &&
        request->requestedSessionTimeout > 0)