Bläddra i källkod

Move create session in front of create EndpointDescription

Martin Lang 6 år sedan
förälder
incheckning
56ad89bf38
1 ändrade filer med 11 tillägg och 11 borttagningar
  1. 11 11
      src/server/ua_services_session.c

+ 11 - 11
src/server/ua_services_session.c

@@ -102,6 +102,17 @@ Service_CreateSession(UA_Server *server, UA_SecureChannel *channel,
             return;
     }
 
+    UA_Session *newSession = NULL;
+    response->responseHeader.serviceResult =
+        UA_SessionManager_createSession(&server->sessionManager, channel, request, &newSession);
+    if(response->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
+        UA_LOG_DEBUG_CHANNEL(server->config.logger, channel,
+                             "Processing CreateSessionRequest failed");
+        return;
+    }
+
+    UA_assert(newSession != NULL);
+
     /* Allocate the response */
     response->serverEndpoints = (UA_EndpointDescription *)
         UA_Array_new(server->config.endpointsSize,
@@ -127,17 +138,6 @@ Service_CreateSession(UA_Server *server, UA_SecureChannel *channel,
                        &response->serverEndpoints[i].endpointUrl);
     }
 
-    UA_Session *newSession = NULL;
-    response->responseHeader.serviceResult =
-        UA_SessionManager_createSession(&server->sessionManager, channel, request, &newSession);
-    if(response->responseHeader.serviceResult != UA_STATUSCODE_GOOD) {
-        UA_LOG_DEBUG_CHANNEL(server->config.logger, channel,
-                             "Processing CreateSessionRequest failed");
-        return;
-    }
-
-    UA_assert(newSession != NULL);
-
     /* Attach the session to the channel. But don't activate for now. */
     UA_Session_attachToSecureChannel(newSession, channel);