Browse Source

refactor(server): Rename UA_AsyncMethodManager to UA_AsyncOperationManager

Julius Pfrommer 5 years ago
parent
commit
c4cde43deb

+ 1 - 1
CMakeLists.txt

@@ -627,7 +627,7 @@ set(internal_headers ${PROJECT_SOURCE_DIR}/deps/open62541_queue.h
                      ${PROJECT_SOURCE_DIR}/src/server/ua_services.h
                      ${PROJECT_SOURCE_DIR}/src/client/ua_client_internal.h
                      ${PROJECT_SOURCE_DIR}/src/server/ua_server_methodqueue.h
-					 ${PROJECT_SOURCE_DIR}/src/server/ua_asyncmethod_manager.h)
+					 ${PROJECT_SOURCE_DIR}/src/server/ua_asyncoperation_manager.h)
 
 # TODO: make client optional
 set(lib_sources ${PROJECT_SOURCE_DIR}/src/ua_types.c

+ 11 - 11
src/server/ua_asyncmethod_manager.h

@@ -11,8 +11,8 @@
  *    Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  */
 
-#ifndef UA_ASYNCMETHOD_MANAGER_H_
-#define UA_ASYNCMETHOD_MANAGER_H_
+#ifndef UA_ASYNCOPERATION_MANAGER_H_
+#define UA_ASYNCOPERATION_MANAGER_H_
 
 #include <open62541/server.h>
 
@@ -40,19 +40,19 @@ typedef struct asyncOperationEntry {
     } response;
 } asyncOperationEntry;
 
-typedef struct UA_AsyncMethodManager {
+typedef struct UA_AsyncOperationManager {
     LIST_HEAD(, asyncOperationEntry) asyncOperations;
     UA_UInt32 currentCount;
-} UA_AsyncMethodManager;
+} UA_AsyncOperationManager;
 
 void
-UA_AsyncMethodManager_init(UA_AsyncMethodManager *amm);
+UA_AsyncOperationManager_init(UA_AsyncOperationManager *amm);
 
 /* Deletes all entries */
-void UA_AsyncMethodManager_clear(UA_AsyncMethodManager *amm);
+void UA_AsyncOperationManager_clear(UA_AsyncOperationManager *amm);
 
 UA_StatusCode
-UA_AsyncMethodManager_createEntry(UA_AsyncMethodManager *amm, UA_Server *server,
+UA_AsyncOperationManager_createEntry(UA_AsyncOperationManager *amm, UA_Server *server,
                                   const UA_NodeId *sessionId, const UA_UInt32 channelId,
                                   const UA_UInt32 requestId, const UA_UInt32 requestHandle,
                                   const UA_AsyncOperationType operationType,
@@ -60,17 +60,17 @@ UA_AsyncMethodManager_createEntry(UA_AsyncMethodManager *amm, UA_Server *server,
 
 /* The pointers amm and current must not be NULL */
 void
-UA_AsyncMethodManager_removeEntry(UA_AsyncMethodManager *amm, asyncOperationEntry *current);
+UA_AsyncOperationManager_removeEntry(UA_AsyncOperationManager *amm, asyncOperationEntry *current);
 
 asyncOperationEntry *
-UA_AsyncMethodManager_getById(UA_AsyncMethodManager *amm, const UA_UInt32 requestId,
+UA_AsyncOperationManager_getById(UA_AsyncOperationManager *amm, const UA_UInt32 requestId,
                               const UA_NodeId *sessionId);
 
 void
-UA_AsyncMethodManager_checkTimeouts(UA_Server *server, UA_AsyncMethodManager *amm);
+UA_AsyncOperationManager_checkTimeouts(UA_Server *server, UA_AsyncOperationManager *amm);
 
 _UA_END_DECLS
 
 #endif
 
-#endif /* UA_ASYNCMETHOD_MANAGER_H_ */
+#endif /* UA_ASYNCOPERATION_MANAGER_H_ */

+ 7 - 7
src/server/ua_server.c

@@ -200,7 +200,7 @@ void UA_Server_delete(UA_Server *server) {
 #if UA_MULTITHREADING >= 100
     UA_Server_removeCallback(server, server->nCBIdResponse);
     UA_Server_MethodQueues_delete(server);
-    UA_AsyncMethodManager_clear(&server->asyncMethodManager);
+    UA_AsyncOperationManager_clear(&server->asyncMethodManager);
 #endif
 
     /* Clean up the Admin Session */
@@ -294,7 +294,7 @@ UA_Server_init(UA_Server *server) {
     UA_SessionManager_init(&server->sessionManager, server);
 
 #if UA_MULTITHREADING >= 100
-    UA_AsyncMethodManager_init(&server->asyncMethodManager);
+    UA_AsyncOperationManager_init(&server->asyncMethodManager);
     UA_Server_MethodQueues_init(server);
     /* Add a regular callback for for checking responmses using a 50ms interval. */
     UA_Server_addRepeatedCallback(server, (UA_ServerCallback)UA_Server_CallMethodResponse, NULL,
@@ -511,7 +511,7 @@ UA_Server_InsertMethodResponse(UA_Server *server, const UA_UInt32 nRequestId,
                                const UA_CallMethodResult *response) {
     /* Grab the open Request, so we can continue to construct the response */
     asyncOperationEntry *data =
-        UA_AsyncMethodManager_getById(&server->asyncMethodManager, nRequestId, nSessionId);
+        UA_AsyncOperationManager_getById(&server->asyncMethodManager, nRequestId, nSessionId);
     if(!data) {
         UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
                        "UA_Server_InsertMethodResponse: can not find UA_CallRequest/UA_CallResponse "
@@ -534,7 +534,7 @@ UA_Server_InsertMethodResponse(UA_Server *server, const UA_UInt32 nRequestId,
     UA_UNLOCK(server->serviceMutex);
     if(!session) {
         UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER, "UA_Server_InsertMethodResponse: Session is gone");
-        UA_AsyncMethodManager_removeEntry(&server->asyncMethodManager, data);
+        UA_AsyncOperationManager_removeEntry(&server->asyncMethodManager, data);
         return;
     }
 
@@ -542,7 +542,7 @@ UA_Server_InsertMethodResponse(UA_Server *server, const UA_UInt32 nRequestId,
     UA_SecureChannel* channel = session->header.channel;
     if(!channel) {
         UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER, "UA_Server_InsertMethodResponse: Channel is gone");
-        UA_AsyncMethodManager_removeEntry(&server->asyncMethodManager, data);
+        UA_AsyncOperationManager_removeEntry(&server->asyncMethodManager, data);
         return;
     }
 
@@ -552,8 +552,8 @@ UA_Server_InsertMethodResponse(UA_Server *server, const UA_UInt32 nRequestId,
                  &UA_TYPES[UA_TYPES_CALLRESPONSE]);
     UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
                  "UA_Server_SendResponse: Response for Req# %u sent", data->requestId);
-    /* Remove this job from the UA_AsyncMethodManager */
-    UA_AsyncMethodManager_removeEntry(&server->asyncMethodManager, data);
+    /* Remove this job from the UA_AsyncOperationManager */
+    UA_AsyncOperationManager_removeEntry(&server->asyncMethodManager, data);
 }
 
 void

+ 16 - 16
src/server/ua_server_async.c

@@ -11,28 +11,28 @@
  *    Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  */
 
-#include "ua_asyncmethod_manager.h"
+#include "ua_asyncoperation_manager.h"
 #include "ua_server_internal.h"
 #include "ua_subscription.h"
 
 #if UA_MULTITHREADING >= 100
 
 void
-UA_AsyncMethodManager_init(UA_AsyncMethodManager *amm) {
-    memset(amm, 0, sizeof(UA_AsyncMethodManager));
+UA_AsyncOperationManager_init(UA_AsyncOperationManager *amm) {
+    memset(amm, 0, sizeof(UA_AsyncOperationManager));
     LIST_INIT(&amm->asyncOperations);
 }
 
 void
-UA_AsyncMethodManager_clear(UA_AsyncMethodManager *amm) {
+UA_AsyncOperationManager_clear(UA_AsyncOperationManager *amm) {
     asyncOperationEntry *current, *temp;
     LIST_FOREACH_SAFE(current, &amm->asyncOperations, pointers, temp) {
-        UA_AsyncMethodManager_removeEntry(amm, current);
+        UA_AsyncOperationManager_removeEntry(amm, current);
     }
 }
 
 asyncOperationEntry *
-UA_AsyncMethodManager_getById(UA_AsyncMethodManager *amm, const UA_UInt32 requestId,
+UA_AsyncOperationManager_getById(UA_AsyncOperationManager *amm, const UA_UInt32 requestId,
                               const UA_NodeId *sessionId) {
     asyncOperationEntry *current = NULL;
     LIST_FOREACH(current, &amm->asyncOperations, pointers) {
@@ -44,7 +44,7 @@ UA_AsyncMethodManager_getById(UA_AsyncMethodManager *amm, const UA_UInt32 reques
 }
 
 UA_StatusCode
-UA_AsyncMethodManager_createEntry(UA_AsyncMethodManager *amm, UA_Server *server,
+UA_AsyncOperationManager_createEntry(UA_AsyncOperationManager *amm, UA_Server *server,
                                   const UA_NodeId *sessionId, const UA_UInt32 channelId,
                                   const UA_UInt32 requestId, const UA_UInt32 requestHandle,
                                   const UA_AsyncOperationType operationType,
@@ -53,14 +53,14 @@ UA_AsyncMethodManager_createEntry(UA_AsyncMethodManager *amm, UA_Server *server,
         UA_calloc(1, sizeof(asyncOperationEntry));
     if(!newentry) {
         UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
-                     "UA_AsyncMethodManager_createEntry: Mem alloc failed.");
+                     "UA_AsyncOperationManager_createEntry: Mem alloc failed.");
         return UA_STATUSCODE_BADOUTOFMEMORY;
     }
 
     UA_StatusCode res = UA_NodeId_copy(sessionId, &newentry->sessionId);
     if(res != UA_STATUSCODE_GOOD) {
         UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
-                     "UA_AsyncMethodManager_createEntry: Mem alloc failed.");
+                     "UA_AsyncOperationManager_createEntry: Mem alloc failed.");
         UA_free(newentry);
         return res;
     }
@@ -76,7 +76,7 @@ UA_AsyncMethodManager_createEntry(UA_AsyncMethodManager *amm, UA_Server *server,
     newentry->response.callResponse.resultsSize = nCountdown;
     if(newentry->response.callResponse.results == NULL) {
         UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
-                     "UA_AsyncMethodManager_createEntry: Mem alloc failed.");
+                     "UA_AsyncOperationManager_createEntry: Mem alloc failed.");
         UA_free(newentry);
         return UA_STATUSCODE_BADOUTOFMEMORY;
     }
@@ -89,14 +89,14 @@ UA_AsyncMethodManager_createEntry(UA_AsyncMethodManager *amm, UA_Server *server,
     LIST_INSERT_HEAD(&amm->asyncOperations, newentry, pointers);
 
     UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
-                 "UA_AsyncMethodManager_createEntry: Chan: %u. Req# %u", channelId, requestId);
+                 "UA_AsyncOperationManager_createEntry: Chan: %u. Req# %u", channelId, requestId);
 
     return UA_STATUSCODE_GOOD;
 }
 
 /* Remove entry and free all allocated data */
 void
-UA_AsyncMethodManager_removeEntry(UA_AsyncMethodManager *amm,
+UA_AsyncOperationManager_removeEntry(UA_AsyncOperationManager *amm,
                                   asyncOperationEntry *current) {
     UA_assert(current);
     LIST_REMOVE(current, pointers);
@@ -108,7 +108,7 @@ UA_AsyncMethodManager_removeEntry(UA_AsyncMethodManager *amm,
 
 /* Check if CallRequest is waiting way too long (120s) */
 void
-UA_AsyncMethodManager_checkTimeouts(UA_Server *server, UA_AsyncMethodManager *amm) {
+UA_AsyncOperationManager_checkTimeouts(UA_Server *server, UA_AsyncOperationManager *amm) {
     asyncOperationEntry* current = NULL;
     asyncOperationEntry* current_tmp = NULL;
     LIST_FOREACH_SAFE(current, &amm->asyncOperations, pointers, current_tmp) {
@@ -124,7 +124,7 @@ UA_AsyncMethodManager_checkTimeouts(UA_Server *server, UA_AsyncMethodManager *am
         /* We got an unfinished CallResponse waiting way too long for being finished.
          * Set the remaining StatusCodes and return. */
         UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
-                       "UA_AsyncMethodManager_checkTimeouts: "
+                       "UA_AsyncOperationManager_checkTimeouts: "
                        "RequestCall #%u was removed due to a timeout (120s)", current->requestId);
 
         /* Get the session */
@@ -134,7 +134,7 @@ UA_AsyncMethodManager_checkTimeouts(UA_Server *server, UA_AsyncMethodManager *am
         UA_UNLOCK(server->serviceMutex);
         if(!session) {
             UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
-                           "UA_AsyncMethodManager_checkTimeouts: Session is gone");
+                           "UA_AsyncOperationManager_checkTimeouts: Session is gone");
             goto remove;
         }
 
@@ -152,7 +152,7 @@ UA_AsyncMethodManager_checkTimeouts(UA_Server *server, UA_AsyncMethodManager *am
         UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
                      "UA_Server_SendResponse: Response for Req# %u sent", current->requestId);
     remove:
-        UA_AsyncMethodManager_removeEntry(amm, current);
+        UA_AsyncOperationManager_removeEntry(amm, current);
     }
 }
 

+ 1 - 1
src/server/ua_server_binary.c

@@ -554,7 +554,7 @@ processMSGDecoded(UA_Server *server, UA_SecureChannel *channel, UA_UInt32 reques
      * there is an error */
     if(requestType == &UA_TYPES[UA_TYPES_CALLREQUEST]) {
         responseHeader->serviceResult =
-            UA_AsyncMethodManager_createEntry(&server->asyncMethodManager, server,
+            UA_AsyncOperationManager_createEntry(&server->asyncMethodManager, server,
                                               &session->sessionId, channel->securityToken.channelId,
                                               requestId, requestHeader->requestHandle,
                                               UA_ASYNCOPERATIONTYPE_CALL,

+ 2 - 2
src/server/ua_server_internal.h

@@ -23,7 +23,7 @@
 #include "ua_connection_internal.h"
 #include "ua_securechannel_manager.h"
 #include "ua_session_manager.h"
-#include "ua_asyncmethod_manager.h"
+#include "ua_asyncoperation_manager.h"
 #include "ua_timer.h"
 #include "ua_util_internal.h"
 #include "ua_workqueue.h"
@@ -100,7 +100,7 @@ struct UA_Server {
     UA_SecureChannelManager secureChannelManager;
     UA_SessionManager sessionManager;
 #if UA_MULTITHREADING >= 100
-    UA_AsyncMethodManager asyncMethodManager;
+    UA_AsyncOperationManager asyncMethodManager;
 #endif
     UA_Session adminSession; /* Local access to the services (for startup and
                               * maintenance) uses this Session with all possible

+ 2 - 2
src/server/ua_server_methodqueue.c

@@ -76,7 +76,7 @@ void
 UA_Server_CheckQueueIntegrity(UA_Server *server, void *data) {
     /* for debugging/testing purposes */
     if(server->config.asyncOperationTimeout <= 0.0) {
-        UA_AsyncMethodManager_checkTimeouts(server, &server->asyncMethodManager);
+        UA_AsyncOperationManager_checkTimeouts(server, &server->asyncMethodManager);
         return;
     }
 
@@ -150,7 +150,7 @@ UA_Server_CheckQueueIntegrity(UA_Server *server, void *data) {
     UA_UNLOCK(server->ua_pending_list_lock);
 
     /* Now we check if we still have pending CallRequests */
-    UA_AsyncMethodManager_checkTimeouts(server, &server->asyncMethodManager);
+    UA_AsyncOperationManager_checkTimeouts(server, &server->asyncMethodManager);
 }
 
 /* Enqueue next MethodRequest */

+ 5 - 5
tests/server/check_server_asyncop.c

@@ -96,17 +96,17 @@ START_TEST(InternalTestingManager) {
     session.sessionId = UA_NODEID_NUMERIC(1, 62541);
     UA_SecureChannel channel;
     UA_SecureChannel_init(&channel);
-    UA_LOG_INFO(&globalServer->config.logger, UA_LOGCATEGORY_SERVER, "* Checking UA_AsyncMethodManager_createEntry: create CallRequests");
+    UA_LOG_INFO(&globalServer->config.logger, UA_LOGCATEGORY_SERVER, "* Checking UA_AsyncOperationManager_createEntry: create CallRequests");
     for (UA_Int32 i = 1; i < 7; i++) {
         UA_StatusCode result =
-            UA_AsyncMethodManager_createEntry(&globalServer->asyncMethodManager, globalServer,
+            UA_AsyncOperationManager_createEntry(&globalServer->asyncMethodManager, globalServer,
                                               &session.sessionId, channel.securityToken.channelId,
                                               i, i, UA_ASYNCOPERATIONTYPE_CALL, 1);
         ck_assert_int_eq(result, UA_STATUSCODE_GOOD);
     }
     UA_fakeSleep(121000);
-    UA_LOG_INFO(&globalServer->config.logger, UA_LOGCATEGORY_SERVER, "* Checking UA_AsyncMethodManager_createEntry: empty CallRequest list");
-    UA_AsyncMethodManager_checkTimeouts(globalServer, &globalServer->asyncMethodManager);
+    UA_LOG_INFO(&globalServer->config.logger, UA_LOGCATEGORY_SERVER, "* Checking UA_AsyncOperationManager_createEntry: empty CallRequest list");
+    UA_AsyncOperationManager_checkTimeouts(globalServer, &globalServer->asyncMethodManager);
     ck_assert_int_eq(globalServer->asyncMethodManager.currentCount, 0);
 }
 END_TEST
@@ -179,7 +179,7 @@ static Suite* method_async_suite(void) {
     tcase_add_test(tc_pending, InternalTestingPendingList);
     suite_add_tcase(s, tc_pending);
 
-    /* UA_AsyncMethodManager */
+    /* UA_AsyncOperationManager */
     TCase* tc_manager = tcase_create("AsyncMethodManager");
     tcase_add_checked_fixture(tc_manager, NULL, NULL);
     tcase_add_test(tc_manager, InternalTestingManager);