mirror of
https://github.com/open62541/open62541.git
synced 2025-06-03 04:00:21 +00:00
refactor(core): Better type-safety for locking primitives
This commit is contained in:
parent
2809e7fc18
commit
beeafc02e9
@ -87,13 +87,11 @@ int gethostname_ecos(char* name, size_t len);
|
||||
#if UA_MULTITHREADING >= 100
|
||||
#error Multithreading unsupported
|
||||
#else
|
||||
#define UA_LOCK_TYPE(mutexName)
|
||||
#define UA_LOCK_TYPE_POINTER(mutexName)
|
||||
#define UA_LOCK_INIT(mutexName)
|
||||
#define UA_LOCK_DESTROY(mutexName)
|
||||
#define UA_LOCK(mutexName)
|
||||
#define UA_UNLOCK(mutexName)
|
||||
#define UA_LOCK_ASSERT(mutexName, num)
|
||||
#define UA_LOCK_INIT(lock)
|
||||
#define UA_LOCK_DESTROY(lock)
|
||||
#define UA_LOCK(lock)
|
||||
#define UA_UNLOCK(lock)
|
||||
#define UA_LOCK_ASSERT(lock, num)
|
||||
#endif
|
||||
|
||||
#include <open62541/architecture_functions.h>
|
||||
|
@ -17,13 +17,11 @@
|
||||
#if UA_MULTITHREADING >= 100
|
||||
#error Multithreading unsupported
|
||||
#else
|
||||
#define UA_LOCK_TYPE(mutexName)
|
||||
#define UA_LOCK_TYPE_POINTER(mutexName)
|
||||
#define UA_LOCK_INIT(mutexName)
|
||||
#define UA_LOCK_DESTROY(mutexName)
|
||||
#define UA_LOCK(mutexName)
|
||||
#define UA_UNLOCK(mutexName)
|
||||
#define UA_LOCK_ASSERT(mutexName, num)
|
||||
#define UA_LOCK_INIT(lock)
|
||||
#define UA_LOCK_DESTROY(lock)
|
||||
#define UA_LOCK(lock)
|
||||
#define UA_UNLOCK(lock)
|
||||
#define UA_LOCK_ASSERT(lock, num)
|
||||
#endif
|
||||
|
||||
#define UA_strncasecmp strncasecmp
|
||||
|
@ -136,31 +136,51 @@ void UA_sleep_ms(unsigned long ms);
|
||||
}
|
||||
|
||||
#if UA_MULTITHREADING >= 100
|
||||
|
||||
#include <pthread.h>
|
||||
#define Sleep(x) sleep(x / 1000)
|
||||
#define UA_LOCK_TYPE(mutexName) pthread_mutex_t mutexName; \
|
||||
pthread_mutexattr_t mutexName##_attr; \
|
||||
int mutexName##Counter;
|
||||
#define UA_LOCK_INIT(mutexName) pthread_mutexattr_init(&mutexName##_attr); \
|
||||
pthread_mutexattr_settype(&mutexName##_attr, PTHREAD_MUTEX_RECURSIVE); \
|
||||
pthread_mutex_init(&mutexName, &mutexName##_attr); \
|
||||
mutexName##Counter = 0;
|
||||
#define UA_LOCK_DESTROY(mutexName) pthread_mutex_destroy(&mutexName); \
|
||||
pthread_mutexattr_destroy(&mutexName##_attr);
|
||||
|
||||
#define UA_LOCK(mutexName) pthread_mutex_lock(&mutexName); \
|
||||
UA_assert(++(mutexName##Counter) == 1); \
|
||||
typedef struct {
|
||||
pthread_mutex_t mutex;
|
||||
pthread_mutexattr_t mutexAttr;
|
||||
int mutexCounter;
|
||||
} UA_Lock;
|
||||
|
||||
#define UA_UNLOCK(mutexName) UA_assert(--(mutexName##Counter) == 0); \
|
||||
pthread_mutex_unlock(&mutexName);
|
||||
#define UA_LOCK_ASSERT(mutexName, num) UA_assert(mutexName##Counter == num);
|
||||
static UA_INLINE void
|
||||
UA_LOCK_INIT(UA_Lock *lock) {
|
||||
pthread_mutexattr_init(&lock->mutexAttr);
|
||||
pthread_mutexattr_settype(&lock->mutexAttr, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutex_init(&lock->mutex, &lock->mutexAttr);
|
||||
lock->mutexCounter = 0;
|
||||
}
|
||||
|
||||
static UA_INLINE void
|
||||
UA_LOCK_DESTROY(UA_Lock *lock) {
|
||||
pthread_mutex_destroy(&lock->mutex);
|
||||
pthread_mutexattr_destroy(&lock->mutexAttr);
|
||||
}
|
||||
|
||||
static UA_INLINE void
|
||||
UA_LOCK(UA_Lock *lock) {
|
||||
pthread_mutex_lock(&lock->mutex);
|
||||
UA_assert(++(lock->mutexCounter) == 1);
|
||||
}
|
||||
|
||||
static UA_INLINE void
|
||||
UA_UNLOCK(UA_Lock *lock) {
|
||||
UA_assert(--(lock->mutexCounter) == 0);
|
||||
pthread_mutex_unlock(&lock->mutex);
|
||||
}
|
||||
|
||||
static UA_INLINE void
|
||||
UA_LOCK_ASSERT(UA_Lock *lock, int num) {
|
||||
UA_assert(lock->mutexCounter == num);
|
||||
}
|
||||
#else
|
||||
#define UA_LOCK_TYPE(mutexName)
|
||||
#define UA_LOCK_INIT(mutexName)
|
||||
#define UA_LOCK_DESTROY(mutexName)
|
||||
#define UA_LOCK(mutexName)
|
||||
#define UA_UNLOCK(mutexName)
|
||||
#define UA_LOCK_ASSERT(mutexName, num)
|
||||
#define UA_LOCK_INIT(lock)
|
||||
#define UA_LOCK_DESTROY(lock)
|
||||
#define UA_LOCK(lock)
|
||||
#define UA_UNLOCK(lock)
|
||||
#define UA_LOCK_ASSERT(lock, num)
|
||||
#endif
|
||||
|
||||
#include <open62541/architecture_functions.h>
|
||||
|
@ -123,13 +123,11 @@ extern void * (*UA_globalRealloc)(void *ptr, size_t size);
|
||||
#if UA_MULTITHREADING >= 100
|
||||
#error Multithreading unsupported
|
||||
#else
|
||||
#define UA_LOCK_TYPE(mutexName)
|
||||
#define UA_LOCK_TYPE_POINTER(mutexName)
|
||||
#define UA_LOCK_INIT(mutexName)
|
||||
#define UA_LOCK_DESTROY(mutexName)
|
||||
#define UA_LOCK(mutexName)
|
||||
#define UA_UNLOCK(mutexName)
|
||||
#define UA_LOCK_ASSERT(mutexName, num)
|
||||
#define UA_LOCK_INIT(lock)
|
||||
#define UA_LOCK_DESTROY(lock)
|
||||
#define UA_LOCK(lock)
|
||||
#define UA_UNLOCK(lock)
|
||||
#define UA_LOCK_ASSERT(lock, num)
|
||||
#endif
|
||||
|
||||
#include <open62541/architecture_functions.h>
|
||||
|
@ -135,12 +135,11 @@ void UA_sleep_ms(unsigned long ms);
|
||||
#if UA_MULTITHREADING >= 100
|
||||
#error Multithreading unsupported
|
||||
#else
|
||||
#define UA_LOCK_TYPE(mutexName)
|
||||
#define UA_LOCK_TYPE_POINTER(mutexName)
|
||||
#define UA_LOCK_INIT(mutexName)
|
||||
#define UA_LOCK_DESTROY(mutexName)
|
||||
#define UA_LOCK(mutexName)
|
||||
#define UA_UNLOCK(mutexName)
|
||||
#define UA_LOCK_INIT(lock)
|
||||
#define UA_LOCK_DESTROY(lock)
|
||||
#define UA_LOCK(lock)
|
||||
#define UA_UNLOCK(lock)
|
||||
#define UA_LOCK_ASSERT(lock, num)
|
||||
#endif
|
||||
|
||||
#include <open62541/architecture_functions.h>
|
||||
|
@ -140,24 +140,45 @@ void UA_sleep_ms(unsigned long ms);
|
||||
#define UA_LOG_SOCKET_ERRNO_GAI_WRAP UA_LOG_SOCKET_ERRNO_WRAP
|
||||
|
||||
#if UA_MULTITHREADING >= 100
|
||||
#define UA_LOCK_TYPE(mutexName) CRITICAL_SECTION mutexName; \
|
||||
int mutexName##Counter;
|
||||
#define UA_LOCK_INIT(mutexName) InitializeCriticalSection(&mutexName); \
|
||||
mutexName##Counter = 0;
|
||||
#define UA_LOCK_DESTROY(mutexName) DeleteCriticalSection(&mutexName);
|
||||
#define UA_LOCK(mutexName) EnterCriticalSection(&mutexName); \
|
||||
UA_assert(++(mutexName##Counter) == 1);
|
||||
#define UA_UNLOCK(mutexName) UA_assert(--(mutexName##Counter) == 0); \
|
||||
LeaveCriticalSection(&mutexName);
|
||||
#define UA_LOCK_ASSERT(mutexName, num) UA_assert(mutexName##Counter == num);
|
||||
|
||||
typedef struct {
|
||||
CRITICAL_SECTION mutex;
|
||||
int mutexCounter;
|
||||
} UA_Lock;
|
||||
|
||||
static UA_INLINE void
|
||||
UA_LOCK_INIT(UA_Lock *lock) {
|
||||
InitializeCriticalSection(&lock->mutex);
|
||||
lock->mutexCounter = 0;
|
||||
}
|
||||
|
||||
static UA_INLINE void
|
||||
UA_LOCK_DESTROY(UA_Lock *lock) {
|
||||
DeleteCriticalSection(&lock->mutex);
|
||||
}
|
||||
|
||||
static UA_INLINE void
|
||||
UA_LOCK(UA_Lock *lock) {
|
||||
EnterCriticalSection(&lock->mutex);
|
||||
UA_assert(++(lock->mutexCounter) == 1);
|
||||
}
|
||||
|
||||
static UA_INLINE void
|
||||
UA_UNLOCK(UA_Lock *lock) {
|
||||
UA_assert(--(lock->mutexCounter) == 0);
|
||||
LeaveCriticalSection(&lock->mutex);
|
||||
}
|
||||
|
||||
static UA_INLINE void
|
||||
UA_LOCK_ASSERT(UA_Lock *lock, int num) {
|
||||
UA_assert(lock->mutexCounter == num);
|
||||
}
|
||||
#else
|
||||
#define UA_LOCK_TYPE(mutexName)
|
||||
#define UA_LOCK_TYPE_POINTER(mutexName)
|
||||
#define UA_LOCK_INIT(mutexName)
|
||||
#define UA_LOCK_DESTROY(mutexName)
|
||||
#define UA_LOCK(mutexName)
|
||||
#define UA_UNLOCK(mutexName)
|
||||
#define UA_LOCK_ASSERT(mutexName, num)
|
||||
#define UA_LOCK_INIT(lock)
|
||||
#define UA_LOCK_DESTROY(lock)
|
||||
#define UA_LOCK(lock)
|
||||
#define UA_UNLOCK(lock)
|
||||
#define UA_LOCK_ASSERT(lock, num)
|
||||
#endif
|
||||
|
||||
#include <open62541/architecture_functions.h>
|
||||
|
@ -190,7 +190,7 @@ THREAD_CALLBACK(ThreadWorker) {
|
||||
UA_CallMethodResult_clear(&response);
|
||||
} else {
|
||||
/* not a good style, but done for simplicity :-) */
|
||||
Sleep(5000);
|
||||
sleep(5);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -90,9 +90,9 @@ UA_UInt16 UA_Server_addNamespace(UA_Server *server, const char* name) {
|
||||
UA_String nameString;
|
||||
nameString.length = strlen(name);
|
||||
nameString.data = (UA_Byte*)(uintptr_t)name;
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_UInt16 retVal = addNamespace(server, nameString);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@ -122,19 +122,19 @@ getNamespaceByName(UA_Server *server, const UA_String namespaceUri,
|
||||
UA_StatusCode
|
||||
UA_Server_getNamespaceByName(UA_Server *server, const UA_String namespaceUri,
|
||||
size_t *foundIndex) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode res = getNamespaceByName(server, namespaceUri, foundIndex);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return res;
|
||||
}
|
||||
|
||||
UA_StatusCode
|
||||
UA_Server_forEachChildNodeCall(UA_Server *server, UA_NodeId parentNodeId,
|
||||
UA_NodeIteratorCallback callback, void *handle) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
const UA_Node *parent = UA_NODESTORE_GET(server, &parentNodeId);
|
||||
if(!parent) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADNODEIDINVALID;
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ UA_Server_forEachChildNodeCall(UA_Server *server, UA_NodeId parentNodeId,
|
||||
UA_Node *parentCopy = UA_Node_copy_alloc(parent);
|
||||
if(!parentCopy) {
|
||||
UA_NODESTORE_RELEASE(server, parent);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADUNEXPECTEDERROR;
|
||||
}
|
||||
|
||||
@ -159,9 +159,9 @@ UA_Server_forEachChildNodeCall(UA_Server *server, UA_NodeId parentNodeId,
|
||||
*UA_NODESTORE_GETREFERENCETYPEID(server, ref->referenceTypeIndex);
|
||||
UA_ReferenceTarget *target;
|
||||
TAILQ_FOREACH(target, &ref->queueHead, queuePointers) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
retval = callback(target->targetId.nodeId, ref->isInverse, refTypeId, handle);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
if(retval != UA_STATUSCODE_GOOD)
|
||||
goto cleanup;
|
||||
}
|
||||
@ -172,7 +172,7 @@ cleanup:
|
||||
UA_free(parentCopy);
|
||||
|
||||
UA_NODESTORE_RELEASE(server, parent);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ serverExecuteRepeatedCallback(UA_Server *server, UA_ApplicationCallback cb,
|
||||
|
||||
/* The server needs to be stopped before it can be deleted */
|
||||
void UA_Server_delete(UA_Server *server) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
|
||||
UA_Server_deleteSecureChannels(server);
|
||||
session_list_entry *current, *temp;
|
||||
@ -231,7 +231,7 @@ void UA_Server_delete(UA_Server *server) {
|
||||
/* Clean up the Admin Session */
|
||||
UA_Session_clear(&server->adminSession, server);
|
||||
|
||||
UA_UNLOCK(server->serviceMutex); /* The timer has its own mutex */
|
||||
UA_UNLOCK(&server->serviceMutex); /* The timer has its own mutex */
|
||||
|
||||
/* Execute all remaining delayed events and clean up the timer */
|
||||
UA_Timer_process(&server->timer, UA_DateTime_nowMonotonic() + 1,
|
||||
@ -242,8 +242,8 @@ void UA_Server_delete(UA_Server *server) {
|
||||
UA_ServerConfig_clean(&server->config);
|
||||
|
||||
#if UA_MULTITHREADING >= 100
|
||||
UA_LOCK_DESTROY(server->networkMutex)
|
||||
UA_LOCK_DESTROY(server->serviceMutex)
|
||||
UA_LOCK_DESTROY(&server->networkMutex);
|
||||
UA_LOCK_DESTROY(&server->serviceMutex);
|
||||
#endif
|
||||
|
||||
/* Delete the server itself */
|
||||
@ -253,14 +253,14 @@ void UA_Server_delete(UA_Server *server) {
|
||||
/* Recurring cleanup. Removing unused and timed-out channels and sessions */
|
||||
static void
|
||||
UA_Server_cleanup(UA_Server *server, void *_) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_DateTime nowMonotonic = UA_DateTime_nowMonotonic();
|
||||
UA_Server_cleanupSessions(server, nowMonotonic);
|
||||
UA_Server_cleanupTimedOutSecureChannels(server, nowMonotonic);
|
||||
#ifdef UA_ENABLE_DISCOVERY
|
||||
UA_Discovery_cleanupTimedOut(server, nowMonotonic);
|
||||
#endif
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
/********************/
|
||||
@ -287,8 +287,8 @@ UA_Server_init(UA_Server *server) {
|
||||
#endif
|
||||
|
||||
#if UA_MULTITHREADING >= 100
|
||||
UA_LOCK_INIT(server->networkMutex)
|
||||
UA_LOCK_INIT(server->serviceMutex)
|
||||
UA_LOCK_INIT(&server->networkMutex);
|
||||
UA_LOCK_INIT(&server->serviceMutex);
|
||||
#endif
|
||||
|
||||
/* Initialize the handling of repeated callbacks */
|
||||
@ -402,11 +402,12 @@ setServerShutdown(UA_Server *server) {
|
||||
UA_StatusCode
|
||||
UA_Server_addTimedCallback(UA_Server *server, UA_ServerCallback callback,
|
||||
void *data, UA_DateTime date, UA_UInt64 *callbackId) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_StatusCode retval = UA_Timer_addTimedCallback(&server->timer,
|
||||
(UA_ApplicationCallback)callback,
|
||||
server, data, date, callbackId);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval =
|
||||
UA_Timer_addTimedCallback(&server->timer,
|
||||
(UA_ApplicationCallback)callback,
|
||||
server, data, date, callbackId);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -423,9 +424,10 @@ UA_StatusCode
|
||||
UA_Server_addRepeatedCallback(UA_Server *server, UA_ServerCallback callback,
|
||||
void *data, UA_Double interval_ms,
|
||||
UA_UInt64 *callbackId) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_StatusCode retval = addRepeatedCallback(server, callback, data, interval_ms, callbackId);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval =
|
||||
addRepeatedCallback(server, callback, data, interval_ms, callbackId);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -439,9 +441,10 @@ changeRepeatedCallbackInterval(UA_Server *server, UA_UInt64 callbackId,
|
||||
UA_StatusCode
|
||||
UA_Server_changeRepeatedCallbackInterval(UA_Server *server, UA_UInt64 callbackId,
|
||||
UA_Double interval_ms) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_StatusCode retval = changeRepeatedCallbackInterval(server, callbackId, interval_ms);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval =
|
||||
changeRepeatedCallbackInterval(server, callbackId, interval_ms);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -452,9 +455,9 @@ removeCallback(UA_Server *server, UA_UInt64 callbackId) {
|
||||
|
||||
void
|
||||
UA_Server_removeCallback(UA_Server *server, UA_UInt64 callbackId) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
removeCallback(server, callbackId);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
UA_StatusCode
|
||||
@ -473,10 +476,10 @@ UA_Server_updateCertificate(UA_Server *server,
|
||||
LIST_FOREACH(current, &server->sessions, pointers) {
|
||||
if(UA_ByteString_equal(oldCertificate,
|
||||
¤t->session.header.channel->securityPolicy->localCertificate)) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_Server_removeSessionByToken(server, ¤t->session.header.authenticationToken,
|
||||
UA_DIAGNOSTICEVENT_CLOSE);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -667,7 +670,7 @@ static void
|
||||
serverExecuteRepeatedCallback(UA_Server *server, UA_ApplicationCallback cb,
|
||||
void *callbackApplication, void *data) {
|
||||
/* Service mutex is not set inside the timer that triggers the callback */
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 0);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 0);
|
||||
cb(callbackApplication, data);
|
||||
}
|
||||
|
||||
@ -705,7 +708,7 @@ UA_Server_run_iterate(UA_Server *server, UA_Boolean waitInternal) {
|
||||
}
|
||||
#endif
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
|
||||
#if defined(UA_ENABLE_DISCOVERY_MULTICAST) && (UA_MULTITHREADING < 200)
|
||||
if(server->config.mdnsEnabled) {
|
||||
@ -721,7 +724,7 @@ UA_Server_run_iterate(UA_Server *server, UA_Boolean waitInternal) {
|
||||
}
|
||||
#endif
|
||||
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
|
||||
now = UA_DateTime_nowMonotonic();
|
||||
timeout = 0;
|
||||
|
@ -22,9 +22,9 @@ UA_AsyncManager_sendAsyncResponse(UA_AsyncManager *am, UA_Server *server,
|
||||
UA_AsyncResponse *ar) {
|
||||
/* Get the session */
|
||||
UA_StatusCode res = UA_STATUSCODE_GOOD;
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_Session* session = UA_Server_getSessionById(server, &ar->sessionId);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
UA_SecureChannel* channel = NULL;
|
||||
UA_ResponseHeader *responseHeader = NULL;
|
||||
if(!session) {
|
||||
@ -88,11 +88,11 @@ static void
|
||||
processAsyncResults(UA_Server *server, void *data) {
|
||||
UA_AsyncManager *am = &server->asyncManager;
|
||||
while(true) {
|
||||
UA_LOCK(am->queueLock);
|
||||
UA_LOCK(&am->queueLock);
|
||||
UA_AsyncOperation *ao = TAILQ_FIRST(&am->resultQueue);
|
||||
if(ao)
|
||||
TAILQ_REMOVE(&am->resultQueue, ao, pointers);
|
||||
UA_UNLOCK(am->queueLock);
|
||||
UA_UNLOCK(&am->queueLock);
|
||||
if(!ao)
|
||||
break;
|
||||
UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
|
||||
@ -113,7 +113,7 @@ checkTimeouts(UA_Server *server, void *_) {
|
||||
UA_AsyncManager *am = &server->asyncManager;
|
||||
const UA_DateTime tNow = UA_DateTime_now();
|
||||
|
||||
UA_LOCK(am->queueLock);
|
||||
UA_LOCK(&am->queueLock);
|
||||
|
||||
/* Loop over the queue of dispatched ops */
|
||||
UA_AsyncOperation *op = NULL, *op_tmp = NULL;
|
||||
@ -144,7 +144,7 @@ checkTimeouts(UA_Server *server, void *_) {
|
||||
"Operation was removed due to a timeout");
|
||||
}
|
||||
|
||||
UA_UNLOCK(am->queueLock);
|
||||
UA_UNLOCK(&am->queueLock);
|
||||
|
||||
/* Integrate async results and send out complete responses */
|
||||
processAsyncResults(server, NULL);
|
||||
@ -157,7 +157,7 @@ UA_AsyncManager_init(UA_AsyncManager *am, UA_Server *server) {
|
||||
TAILQ_INIT(&am->newQueue);
|
||||
TAILQ_INIT(&am->dispatchedQueue);
|
||||
TAILQ_INIT(&am->resultQueue);
|
||||
UA_LOCK_INIT(am->queueLock);
|
||||
UA_LOCK_INIT(&am->queueLock);
|
||||
|
||||
/* Add a regular callback for cleanup and sending finished responses at a
|
||||
* 100s interval. */
|
||||
@ -172,7 +172,7 @@ UA_AsyncManager_clear(UA_AsyncManager *am, UA_Server *server) {
|
||||
UA_AsyncOperation *ar;
|
||||
|
||||
/* Clean up queues */
|
||||
UA_LOCK(am->queueLock);
|
||||
UA_LOCK(&am->queueLock);
|
||||
while((ar = TAILQ_FIRST(&am->newQueue))) {
|
||||
TAILQ_REMOVE(&am->resultQueue, ar, pointers);
|
||||
UA_AsyncOperation_delete(ar);
|
||||
@ -185,7 +185,7 @@ UA_AsyncManager_clear(UA_AsyncManager *am, UA_Server *server) {
|
||||
TAILQ_REMOVE(&am->resultQueue, ar, pointers);
|
||||
UA_AsyncOperation_delete(ar);
|
||||
}
|
||||
UA_UNLOCK(am->queueLock);
|
||||
UA_UNLOCK(&am->queueLock);
|
||||
|
||||
/* Remove responses */
|
||||
UA_AsyncResponse *current, *temp;
|
||||
@ -194,7 +194,7 @@ UA_AsyncManager_clear(UA_AsyncManager *am, UA_Server *server) {
|
||||
}
|
||||
|
||||
/* Delete all locks */
|
||||
UA_LOCK_DESTROY(am->queueLock);
|
||||
UA_LOCK_DESTROY(&am->queueLock);
|
||||
}
|
||||
|
||||
UA_StatusCode
|
||||
@ -268,11 +268,11 @@ UA_AsyncManager_createAsyncOp(UA_AsyncManager *am, UA_Server *server,
|
||||
ao->index = opIndex;
|
||||
ao->parent = ar;
|
||||
|
||||
UA_LOCK(am->queueLock);
|
||||
UA_LOCK(&am->queueLock);
|
||||
TAILQ_INSERT_TAIL(&am->newQueue, ao, pointers);
|
||||
am->opsCount++;
|
||||
ar->opCountdown++;
|
||||
UA_UNLOCK(am->queueLock);
|
||||
UA_UNLOCK(&am->queueLock);
|
||||
|
||||
if(server->config.asyncOperationNotifyCallback)
|
||||
server->config.asyncOperationNotifyCallback(server);
|
||||
@ -289,7 +289,7 @@ UA_Server_getAsyncOperationNonBlocking(UA_Server *server, UA_AsyncOperationType
|
||||
|
||||
UA_Boolean bRV = false;
|
||||
*type = UA_ASYNCOPERATIONTYPE_INVALID;
|
||||
UA_LOCK(am->queueLock);
|
||||
UA_LOCK(&am->queueLock);
|
||||
UA_AsyncOperation *ao = TAILQ_FIRST(&am->newQueue);
|
||||
if(ao) {
|
||||
TAILQ_REMOVE(&am->newQueue, ao, pointers);
|
||||
@ -301,7 +301,7 @@ UA_Server_getAsyncOperationNonBlocking(UA_Server *server, UA_AsyncOperationType
|
||||
*timeout = ao->parent->timeout;
|
||||
bRV = true;
|
||||
}
|
||||
UA_UNLOCK(am->queueLock);
|
||||
UA_UNLOCK(&am->queueLock);
|
||||
|
||||
return bRV;
|
||||
}
|
||||
@ -328,7 +328,7 @@ UA_Server_setAsyncOperationResult(UA_Server *server,
|
||||
return;
|
||||
}
|
||||
|
||||
UA_LOCK(am->queueLock);
|
||||
UA_LOCK(&am->queueLock);
|
||||
|
||||
/* See if the operation is still in the dispatched queue. Otherwise it has
|
||||
* been removed due to a timeout.
|
||||
@ -347,7 +347,7 @@ UA_Server_setAsyncOperationResult(UA_Server *server,
|
||||
if(!found) {
|
||||
UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
|
||||
"UA_Server_SetAsyncMethodResult: The operation has timed out");
|
||||
UA_UNLOCK(am->queueLock);
|
||||
UA_UNLOCK(&am->queueLock);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -364,7 +364,7 @@ UA_Server_setAsyncOperationResult(UA_Server *server,
|
||||
TAILQ_REMOVE(&am->dispatchedQueue, ao, pointers);
|
||||
TAILQ_INSERT_TAIL(&am->resultQueue, ao, pointers);
|
||||
|
||||
UA_UNLOCK(am->queueLock);
|
||||
UA_UNLOCK(&am->queueLock);
|
||||
|
||||
UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
|
||||
"Set the result from the worker thread");
|
||||
|
@ -62,7 +62,7 @@ typedef struct {
|
||||
|
||||
/* Operations for the workers. The queues are all FIFO: Put in at the tail,
|
||||
* take out at the head.*/
|
||||
UA_LOCK_TYPE(queueLock)
|
||||
UA_Lock queueLock;
|
||||
UA_AsyncOperationQueue newQueue; /* New operations for the workers */
|
||||
UA_AsyncOperationQueue dispatchedQueue; /* Operations taken by a worker. When a result is
|
||||
* returned, we search for the op here to see if it
|
||||
|
@ -517,9 +517,9 @@ processMSGDecoded(UA_Server *server, UA_SecureChannel *channel, UA_UInt32 reques
|
||||
if(requestType == &UA_TYPES[UA_TYPES_CREATESESSIONREQUEST] ||
|
||||
requestType == &UA_TYPES[UA_TYPES_ACTIVATESESSIONREQUEST] ||
|
||||
requestType == &UA_TYPES[UA_TYPES_CLOSESESSIONREQUEST]) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
((UA_ChannelService)(uintptr_t)service)(server, channel, request, response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
/* Store the authentication token so we can help fuzzing by setting
|
||||
* these values in the next request automatically */
|
||||
@ -535,9 +535,10 @@ processMSGDecoded(UA_Server *server, UA_SecureChannel *channel, UA_UInt32 reques
|
||||
UA_Session *session = NULL;
|
||||
UA_StatusCode retval = UA_STATUSCODE_GOOD;
|
||||
if(!UA_NodeId_isNull(&requestHeader->authenticationToken)) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
retval = getBoundSession(server, channel, &requestHeader->authenticationToken, &session);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
retval = getBoundSession(server, channel, &requestHeader->authenticationToken,
|
||||
&session);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
if(retval != UA_STATUSCODE_GOOD)
|
||||
return sendServiceFault(channel, requestId, requestHeader->requestHandle,
|
||||
responseType, retval);
|
||||
@ -580,10 +581,10 @@ processMSGDecoded(UA_Server *server, UA_SecureChannel *channel, UA_UInt32 reques
|
||||
requestType->binaryEncodingId.identifier.numeric);
|
||||
#endif
|
||||
if(session != &anonymousSession) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_Server_removeSessionByToken(server, &session->header.authenticationToken,
|
||||
UA_DIAGNOSTICEVENT_ABORT);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
}
|
||||
return sendServiceFault(channel, requestId, requestHeader->requestHandle,
|
||||
responseType, UA_STATUSCODE_BADSESSIONNOTACTIVATED);
|
||||
@ -595,9 +596,9 @@ processMSGDecoded(UA_Server *server, UA_SecureChannel *channel, UA_UInt32 reques
|
||||
#ifdef UA_ENABLE_SUBSCRIPTIONS
|
||||
/* The publish request is not answered immediately */
|
||||
if(requestType == &UA_TYPES[UA_TYPES_PUBLISHREQUEST]) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_Publish(server, session, &request->publishRequest, requestId);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_GOOD;
|
||||
}
|
||||
#endif
|
||||
@ -606,10 +607,10 @@ processMSGDecoded(UA_Server *server, UA_SecureChannel *channel, UA_UInt32 reques
|
||||
/* The call request might not be answered immediately */
|
||||
if(requestType == &UA_TYPES[UA_TYPES_CALLREQUEST]) {
|
||||
UA_Boolean finished = true;
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CallAsync(server, session, requestId, &request->callRequest,
|
||||
&response->callResponse, &finished);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
|
||||
/* Async method calls remain. Don't send a response now */
|
||||
if(!finished)
|
||||
@ -621,9 +622,9 @@ processMSGDecoded(UA_Server *server, UA_SecureChannel *channel, UA_UInt32 reques
|
||||
#endif
|
||||
|
||||
/* Dispatch the synchronous service call and send the response */
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
service(server, session, request, response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return sendResponse(server, session, channel, requestId, response, responseType);
|
||||
}
|
||||
|
||||
|
@ -119,19 +119,19 @@ register_server_with_discovery_server(UA_Server *server,
|
||||
UA_StatusCode
|
||||
UA_Server_register_discovery(UA_Server *server, UA_Client *client,
|
||||
const char* semaphoreFilePath) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = register_server_with_discovery_server(server, client,
|
||||
false, semaphoreFilePath);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
UA_StatusCode
|
||||
UA_Server_unregister_discovery(UA_Server *server, UA_Client *client) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = register_server_with_discovery_server(server, client,
|
||||
true, NULL);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -147,8 +147,8 @@ struct UA_Server {
|
||||
#endif
|
||||
|
||||
#if UA_MULTITHREADING >= 100
|
||||
UA_LOCK_TYPE(networkMutex)
|
||||
UA_LOCK_TYPE(serviceMutex)
|
||||
UA_Lock networkMutex;
|
||||
UA_Lock serviceMutex;
|
||||
#endif
|
||||
|
||||
/* Statistics */
|
||||
|
@ -571,14 +571,14 @@ readMonitoredItems(UA_Server *server, const UA_NodeId *sessionId, void *sessionC
|
||||
0, &UA_TYPES[UA_TYPES_UINT32]);
|
||||
|
||||
/* Get the Session */
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_Session *session = UA_Server_getSessionById(server, sessionId);
|
||||
if(!session) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADINTERNALERROR;
|
||||
}
|
||||
if(inputSize == 0 || !input[0].data) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
|
||||
}
|
||||
|
||||
@ -586,7 +586,7 @@ readMonitoredItems(UA_Server *server, const UA_NodeId *sessionId, void *sessionC
|
||||
UA_UInt32 subscriptionId = *((UA_UInt32*)(input[0].data));
|
||||
UA_Subscription *subscription = UA_Session_getSubscriptionById(session, subscriptionId);
|
||||
if(!subscription) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
|
||||
}
|
||||
|
||||
@ -597,7 +597,7 @@ readMonitoredItems(UA_Server *server, const UA_NodeId *sessionId, void *sessionC
|
||||
++sizeOfOutput;
|
||||
}
|
||||
if(sizeOfOutput == 0) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_GOOD;
|
||||
}
|
||||
|
||||
@ -605,13 +605,13 @@ readMonitoredItems(UA_Server *server, const UA_NodeId *sessionId, void *sessionC
|
||||
UA_UInt32 *clientHandles = (UA_UInt32*)
|
||||
UA_Array_new(sizeOfOutput, &UA_TYPES[UA_TYPES_UINT32]);
|
||||
if(!clientHandles) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADOUTOFMEMORY;
|
||||
}
|
||||
UA_UInt32 *serverHandles = (UA_UInt32*)
|
||||
UA_Array_new(sizeOfOutput, &UA_TYPES[UA_TYPES_UINT32]);
|
||||
if(!serverHandles) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
UA_free(clientHandles);
|
||||
return UA_STATUSCODE_BADOUTOFMEMORY;
|
||||
}
|
||||
@ -626,7 +626,7 @@ readMonitoredItems(UA_Server *server, const UA_NodeId *sessionId, void *sessionC
|
||||
UA_Variant_setArray(&output[0], serverHandles, sizeOfOutput, &UA_TYPES[UA_TYPES_UINT32]);
|
||||
UA_Variant_setArray(&output[1], clientHandles, sizeOfOutput, &UA_TYPES[UA_TYPES_UINT32]);
|
||||
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_GOOD;
|
||||
}
|
||||
#endif /* defined(UA_ENABLE_METHODCALLS) && defined(UA_ENABLE_SUBSCRIPTIONS) */
|
||||
|
@ -40,13 +40,13 @@ getUserWriteMask(UA_Server *server, const UA_Session *session,
|
||||
if(session == &server->adminSession)
|
||||
return 0xFFFFFFFF; /* the local admin user has all rights */
|
||||
UA_UInt32 mask = head->writeMask;
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
mask &= server->config.accessControl.
|
||||
getUserRightsMask(server, &server->config.accessControl,
|
||||
session ? &session->sessionId : NULL,
|
||||
session ? session->sessionHandle : NULL,
|
||||
&head->nodeId, head->context);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
return mask;
|
||||
}
|
||||
|
||||
@ -64,13 +64,13 @@ getUserAccessLevel(UA_Server *server, const UA_Session *session,
|
||||
if(session == &server->adminSession)
|
||||
return 0xFF; /* the local admin user has all rights */
|
||||
UA_Byte retval = node->accessLevel;
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
retval &= server->config.accessControl.
|
||||
getUserAccessLevel(server, &server->config.accessControl,
|
||||
session ? &session->sessionId : NULL,
|
||||
session ? session->sessionHandle : NULL,
|
||||
&node->head.nodeId, node->head.context);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ getUserExecutable(UA_Server *server, const UA_Session *session,
|
||||
const UA_MethodNode *node) {
|
||||
if(session == &server->adminSession)
|
||||
return true; /* the local admin user has all rights */
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
UA_Boolean userExecutable = node->executable;
|
||||
userExecutable &=
|
||||
server->config.accessControl.
|
||||
@ -87,7 +87,7 @@ getUserExecutable(UA_Server *server, const UA_Session *session,
|
||||
session ? &session->sessionId : NULL,
|
||||
session ? session->sessionHandle : NULL,
|
||||
&node->head.nodeId, node->head.context);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
return userExecutable;
|
||||
}
|
||||
|
||||
@ -124,13 +124,13 @@ readValueAttributeFromNode(UA_Server *server, UA_Session *session,
|
||||
UA_NumericRange *rangeptr) {
|
||||
/* Update the value by the user callback */
|
||||
if(vn->value.data.callback.onRead) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
vn->value.data.callback.onRead(server,
|
||||
session ? &session->sessionId : NULL,
|
||||
session ? session->sessionHandle : NULL,
|
||||
&vn->head.nodeId, vn->head.context, rangeptr,
|
||||
&vn->value.data.value);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
vn = (const UA_VariableNode*)UA_NODESTORE_GET(server, &vn->head.nodeId);
|
||||
if(!vn)
|
||||
return UA_STATUSCODE_BADNODEIDUNKNOWN;
|
||||
@ -158,14 +158,14 @@ readValueAttributeFromDataSource(UA_Server *server, UA_Session *session,
|
||||
timestamps == UA_TIMESTAMPSTORETURN_BOTH);
|
||||
UA_DataValue v2;
|
||||
UA_DataValue_init(&v2);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = vn->value.dataSource.
|
||||
read(server,
|
||||
session ? &session->sessionId : NULL,
|
||||
session ? session->sessionHandle : NULL,
|
||||
&vn->head.nodeId, vn->head.context,
|
||||
sourceTimeStamp, rangeptr, &v2);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
if(v2.hasValue && v2.value.storageType == UA_VARIANT_DATA_NODELETE) {
|
||||
retval = UA_DataValue_copy(&v2, v);
|
||||
UA_DataValue_clear(&v2);
|
||||
@ -581,7 +581,7 @@ void
|
||||
Service_Read(UA_Server *server, UA_Session *session,
|
||||
const UA_ReadRequest *request, UA_ReadResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing ReadRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Check if the timestampstoreturn is valid */
|
||||
if(request->timestampsToReturn > UA_TIMESTAMPSTORETURN_NEITHER) {
|
||||
@ -602,7 +602,7 @@ Service_Read(UA_Server *server, UA_Session *session,
|
||||
return;
|
||||
}
|
||||
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
response->responseHeader.serviceResult =
|
||||
UA_Server_processServiceOperations(server, session,
|
||||
@ -617,7 +617,7 @@ UA_DataValue
|
||||
UA_Server_readWithSession(UA_Server *server, UA_Session *session,
|
||||
const UA_ReadValueId *item,
|
||||
UA_TimestampsToReturn timestampsToReturn) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
UA_DataValue dv;
|
||||
UA_DataValue_init(&dv);
|
||||
@ -641,14 +641,14 @@ UA_Server_readWithSession(UA_Server *server, UA_Session *session,
|
||||
UA_DataValue
|
||||
readAttribute(UA_Server *server, const UA_ReadValueId *item,
|
||||
UA_TimestampsToReturn timestamps) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
return UA_Server_readWithSession(server, &server->adminSession, item, timestamps);
|
||||
}
|
||||
|
||||
UA_StatusCode
|
||||
readWithReadValue(UA_Server *server, const UA_NodeId *nodeId,
|
||||
const UA_AttributeId attributeId, void *v) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Call the read service */
|
||||
UA_ReadValueId item;
|
||||
@ -684,9 +684,9 @@ readWithReadValue(UA_Server *server, const UA_NodeId *nodeId,
|
||||
UA_DataValue
|
||||
UA_Server_read(UA_Server *server, const UA_ReadValueId *item,
|
||||
UA_TimestampsToReturn timestamps) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_DataValue dv = readAttribute(server, item, timestamps);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return dv;
|
||||
}
|
||||
|
||||
@ -695,9 +695,9 @@ UA_Server_read(UA_Server *server, const UA_ReadValueId *item,
|
||||
UA_StatusCode
|
||||
__UA_Server_read(UA_Server *server, const UA_NodeId *nodeId,
|
||||
const UA_AttributeId attributeId, void *v) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = readWithReadValue(server, nodeId, attributeId, v);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -705,7 +705,7 @@ UA_StatusCode
|
||||
readObjectProperty(UA_Server *server, const UA_NodeId objectId,
|
||||
const UA_QualifiedName propertyName,
|
||||
UA_Variant *value) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Create a BrowsePath to get the target NodeId */
|
||||
UA_RelativePathElement rpe;
|
||||
@ -742,9 +742,9 @@ UA_StatusCode
|
||||
UA_Server_readObjectProperty(UA_Server *server, const UA_NodeId objectId,
|
||||
const UA_QualifiedName propertyName,
|
||||
UA_Variant *value) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = readObjectProperty(server, objectId, propertyName, value);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -1324,32 +1324,32 @@ writeNodeValueAttribute(UA_Server *server, UA_Session *session,
|
||||
if(retval == UA_STATUSCODE_GOOD &&
|
||||
node->head.nodeClass == UA_NODECLASS_VARIABLE &&
|
||||
server->config.historyDatabase.setValue) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
server->config.historyDatabase.
|
||||
setValue(server, server->config.historyDatabase.context,
|
||||
&session->sessionId, session->sessionHandle,
|
||||
&node->head.nodeId, node->historizing, &adjustedValue);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
#endif
|
||||
/* Callback after writing */
|
||||
if(retval == UA_STATUSCODE_GOOD && node->value.data.callback.onWrite) {
|
||||
UA_UNLOCK(server->serviceMutex)
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
node->value.data.callback.
|
||||
onWrite(server, &session->sessionId, session->sessionHandle,
|
||||
&node->head.nodeId, node->head.context,
|
||||
rangeptr, &adjustedValue);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
|
||||
}
|
||||
} else {
|
||||
if(node->value.dataSource.write) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
retval = node->value.dataSource.
|
||||
write(server, &session->sessionId, session->sessionHandle,
|
||||
&node->head.nodeId, node->head.context,
|
||||
rangeptr, &adjustedValue);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
} else {
|
||||
retval = UA_STATUSCODE_BADWRITENOTSUPPORTED;
|
||||
}
|
||||
@ -1632,7 +1632,7 @@ Service_Write(UA_Server *server, UA_Session *session,
|
||||
UA_assert(session != NULL);
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing WriteRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(server->config.maxNodesPerWrite != 0 &&
|
||||
request->nodesToWriteSize > server->config.maxNodesPerWrite) {
|
||||
@ -1640,7 +1640,7 @@ Service_Write(UA_Server *server, UA_Session *session,
|
||||
return;
|
||||
}
|
||||
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
response->responseHeader.serviceResult =
|
||||
UA_Server_processServiceOperations(server, session,
|
||||
@ -1654,9 +1654,9 @@ Service_Write(UA_Server *server, UA_Session *session,
|
||||
UA_StatusCode
|
||||
UA_Server_write(UA_Server *server, const UA_WriteValue *value) {
|
||||
UA_StatusCode res = UA_STATUSCODE_GOOD;
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Operation_Write(server, &server->adminSession, NULL, value, &res);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -1665,10 +1665,10 @@ UA_StatusCode
|
||||
__UA_Server_write(UA_Server *server, const UA_NodeId *nodeId,
|
||||
const UA_AttributeId attributeId,
|
||||
const UA_DataType *attr_type, const void *attr) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode res = writeAttribute(server, &server->adminSession,
|
||||
nodeId, attributeId, attr, attr_type);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -1677,7 +1677,7 @@ UA_StatusCode
|
||||
writeAttribute(UA_Server *server, UA_Session *session,
|
||||
const UA_NodeId *nodeId, const UA_AttributeId attributeId,
|
||||
const void *attr, const UA_DataType *attr_type) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
UA_WriteValue wvalue;
|
||||
UA_WriteValue_init(&wvalue);
|
||||
@ -1717,7 +1717,7 @@ Service_HistoryRead(UA_Server *server, UA_Session *session,
|
||||
const UA_HistoryReadRequest *request,
|
||||
UA_HistoryReadResponse *response) {
|
||||
UA_assert(session != NULL);
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(request->historyReadDetails.encoding != UA_EXTENSIONOBJECT_DECODED) {
|
||||
response->responseHeader.serviceResult = UA_STATUSCODE_BADNOTSUPPORTED;
|
||||
@ -1799,7 +1799,7 @@ Service_HistoryRead(UA_Server *server, UA_Session *session,
|
||||
data, historyDataType);
|
||||
historyData[i] = data;
|
||||
}
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
readHistory(server, server->config.historyDatabase.context,
|
||||
&session->sessionId, session->sessionHandle,
|
||||
&request->requestHeader,
|
||||
@ -1808,7 +1808,7 @@ Service_HistoryRead(UA_Server *server, UA_Session *session,
|
||||
request->releaseContinuationPoints,
|
||||
request->nodesToReadSize, request->nodesToRead,
|
||||
response, historyData);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_free(historyData);
|
||||
}
|
||||
|
||||
@ -1817,7 +1817,7 @@ Service_HistoryUpdate(UA_Server *server, UA_Session *session,
|
||||
const UA_HistoryUpdateRequest *request,
|
||||
UA_HistoryUpdateResponse *response) {
|
||||
UA_assert(session != NULL);
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
response->resultsSize = request->historyUpdateDetailsSize;
|
||||
response->results = (UA_HistoryUpdateResult*)
|
||||
@ -1844,14 +1844,14 @@ Service_HistoryUpdate(UA_Server *server, UA_Session *session,
|
||||
response->results[i].statusCode = UA_STATUSCODE_BADNOTSUPPORTED;
|
||||
continue;
|
||||
}
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
server->config.historyDatabase.
|
||||
updateData(server, server->config.historyDatabase.context,
|
||||
&session->sessionId, session->sessionHandle,
|
||||
&request->requestHeader,
|
||||
(UA_UpdateDataDetails*)updateDetailsData,
|
||||
&response->results[i]);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1860,14 +1860,14 @@ Service_HistoryUpdate(UA_Server *server, UA_Session *session,
|
||||
response->results[i].statusCode = UA_STATUSCODE_BADNOTSUPPORTED;
|
||||
continue;
|
||||
}
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
server->config.historyDatabase.
|
||||
deleteRawModified(server, server->config.historyDatabase.context,
|
||||
&session->sessionId, session->sessionHandle,
|
||||
&request->requestHeader,
|
||||
(UA_DeleteRawModifiedDetails*)updateDetailsData,
|
||||
&response->results[i]);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1881,9 +1881,9 @@ UA_StatusCode
|
||||
UA_Server_writeObjectProperty(UA_Server *server, const UA_NodeId objectId,
|
||||
const UA_QualifiedName propertyName,
|
||||
const UA_Variant value) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retVal = writeObjectProperty(server, objectId, propertyName, value);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@ -1891,7 +1891,7 @@ UA_StatusCode
|
||||
writeObjectProperty(UA_Server *server, const UA_NodeId objectId,
|
||||
const UA_QualifiedName propertyName,
|
||||
const UA_Variant value) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
UA_RelativePathElement rpe;
|
||||
UA_RelativePathElement_init(&rpe);
|
||||
rpe.referenceTypeId = UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY);
|
||||
@ -1927,8 +1927,8 @@ UA_Server_writeObjectProperty_scalar(UA_Server *server, const UA_NodeId objectId
|
||||
UA_Variant var;
|
||||
UA_Variant_init(&var);
|
||||
UA_Variant_setScalar(&var, (void*)(uintptr_t)value, type);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = writeObjectProperty(server, objectId, propertyName, var);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ void Service_FindServers(UA_Server *server, UA_Session *session,
|
||||
const UA_FindServersRequest *request,
|
||||
UA_FindServersResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing FindServersRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Return the server itself? */
|
||||
UA_Boolean foundSelf = false;
|
||||
@ -200,7 +200,7 @@ void
|
||||
Service_GetEndpoints(UA_Server *server, UA_Session *session,
|
||||
const UA_GetEndpointsRequest *request,
|
||||
UA_GetEndpointsResponse *response) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* If the client expects to see a specific endpointurl, mirror it back. If
|
||||
* not, clone the endpoints with the discovery url of all networklayers. */
|
||||
@ -293,7 +293,8 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
|
||||
UA_StatusCode **responseConfigurationResults,
|
||||
size_t *responseDiagnosticInfosSize,
|
||||
UA_DiagnosticInfo *responseDiagnosticInfos) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Find the server from the request in the registered list */
|
||||
registeredServer_list_entry* current;
|
||||
registeredServer_list_entry *registeredServer_entry = NULL;
|
||||
@ -394,11 +395,11 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
|
||||
}
|
||||
|
||||
if(server->discoveryManager.registerServerCallback) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
server->discoveryManager.
|
||||
registerServerCallback(requestServer,
|
||||
server->discoveryManager.registerServerCallbackData);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
// server found, remove from list
|
||||
@ -438,11 +439,11 @@ process_RegisterServer(UA_Server *server, UA_Session *session,
|
||||
// registered before, then crashed, restarts and registeres again. In that case the entry is not deleted
|
||||
// and the callback would not be called.
|
||||
if(server->discoveryManager.registerServerCallback) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
server->discoveryManager.
|
||||
registerServerCallback(requestServer,
|
||||
server->discoveryManager.registerServerCallbackData);
|
||||
UA_LOCK(server->serviceMutex)
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
// copy the data from the request into the list
|
||||
@ -456,7 +457,7 @@ void Service_RegisterServer(UA_Server *server, UA_Session *session,
|
||||
UA_RegisterServerResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing RegisterServerRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
process_RegisterServer(server, session, &request->requestHeader, &request->server, 0,
|
||||
NULL, &response->responseHeader, 0, NULL, 0, NULL);
|
||||
}
|
||||
@ -466,7 +467,7 @@ void Service_RegisterServer2(UA_Server *server, UA_Session *session,
|
||||
UA_RegisterServer2Response *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing RegisterServer2Request");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
process_RegisterServer(server, session, &request->requestHeader, &request->server,
|
||||
request->discoveryConfigurationSize, request->discoveryConfiguration,
|
||||
&response->responseHeader, &response->configurationResultsSize,
|
||||
@ -544,7 +545,7 @@ void UA_Discovery_cleanupTimedOut(UA_Server *server, UA_DateTime nowMonotonic) {
|
||||
static void
|
||||
periodicServerRegister(UA_Server *server, void *data) {
|
||||
UA_assert(data != NULL);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
|
||||
struct PeriodicServerRegisterCallback *cb = (struct PeriodicServerRegisterCallback *)data;
|
||||
|
||||
@ -589,7 +590,7 @@ periodicServerRegister(UA_Server *server, void *data) {
|
||||
|
||||
cb->this_interval = nextInterval;
|
||||
changeRepeatedCallbackInterval(server, cb->id, nextInterval);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -604,7 +605,7 @@ periodicServerRegister(UA_Server *server, void *data) {
|
||||
if(retval == UA_STATUSCODE_GOOD)
|
||||
cb->registered = true;
|
||||
}
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
UA_StatusCode
|
||||
@ -614,18 +615,18 @@ UA_Server_addPeriodicServerRegisterCallback(UA_Server *server,
|
||||
UA_Double intervalMs,
|
||||
UA_Double delayFirstRegisterMs,
|
||||
UA_UInt64 *periodicCallbackId) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
/* No valid server URL */
|
||||
if(!discoveryServerUrl) {
|
||||
UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_SERVER,
|
||||
"No discovery server URL provided");
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADINTERNALERROR;
|
||||
}
|
||||
|
||||
|
||||
if (client->connection.state != UA_CONNECTIONSTATE_CLOSED) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADINVALIDSTATE;
|
||||
}
|
||||
|
||||
@ -651,7 +652,7 @@ UA_Server_addPeriodicServerRegisterCallback(UA_Server *server,
|
||||
struct PeriodicServerRegisterCallback* cb = (struct PeriodicServerRegisterCallback*)
|
||||
UA_malloc(sizeof(struct PeriodicServerRegisterCallback));
|
||||
if(!cb) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADOUTOFMEMORY;
|
||||
}
|
||||
|
||||
@ -666,7 +667,7 @@ UA_Server_addPeriodicServerRegisterCallback(UA_Server *server,
|
||||
cb->discovery_server_url = (char*)UA_malloc(len+1);
|
||||
if (!cb->discovery_server_url) {
|
||||
UA_free(cb);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADOUTOFMEMORY;
|
||||
}
|
||||
memcpy(cb->discovery_server_url, discoveryServerUrl, len+1);
|
||||
@ -680,7 +681,7 @@ UA_Server_addPeriodicServerRegisterCallback(UA_Server *server,
|
||||
"Could not create periodic job for server register. "
|
||||
"StatusCode %s", UA_StatusCode_name(retval));
|
||||
UA_free(cb);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -691,7 +692,7 @@ UA_Server_addPeriodicServerRegisterCallback(UA_Server *server,
|
||||
if(!newEntry) {
|
||||
removeCallback(server, cb->id);
|
||||
UA_free(cb);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADOUTOFMEMORY;
|
||||
}
|
||||
newEntry->callback = cb;
|
||||
@ -700,7 +701,7 @@ UA_Server_addPeriodicServerRegisterCallback(UA_Server *server,
|
||||
|
||||
if(periodicCallbackId)
|
||||
*periodicCallbackId = cb->id;
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_GOOD;
|
||||
}
|
||||
|
||||
@ -708,10 +709,10 @@ void
|
||||
UA_Server_setRegisterServerCallback(UA_Server *server,
|
||||
UA_Server_registerServerCallback cb,
|
||||
void* data) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
server->discoveryManager.registerServerCallback = cb;
|
||||
server->discoveryManager.registerServerCallbackData = data;
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
#endif /* UA_ENABLE_DISCOVERY */
|
||||
|
@ -174,7 +174,7 @@ entryMatchesCapabilityFilter(size_t serverCapabilityFilterSize, UA_String *serve
|
||||
void Service_FindServersOnNetwork(UA_Server *server, UA_Session *session,
|
||||
const UA_FindServersOnNetworkRequest *request,
|
||||
UA_FindServersOnNetworkResponse *response) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if (!server->config.mdnsEnabled) {
|
||||
response->responseHeader.serviceResult = UA_STATUSCODE_BADNOTIMPLEMENTED;
|
||||
@ -278,10 +278,10 @@ void
|
||||
UA_Server_setServerOnNetworkCallback(UA_Server *server,
|
||||
UA_Server_serverOnNetworkCallback cb,
|
||||
void* data) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
server->discoveryManager.serverOnNetworkCallback = cb;
|
||||
server->discoveryManager.serverOnNetworkCallbackData = data;
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -236,12 +236,12 @@ callWithMethodAndObject(UA_Server *server, UA_Session *session,
|
||||
/* Verify access rights */
|
||||
UA_Boolean executable = method->executable;
|
||||
if(session != &server->adminSession) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
executable = executable && server->config.accessControl.
|
||||
getUserExecutableOnObject(server, &server->config.accessControl, &session->sessionId,
|
||||
session->sessionHandle, &request->methodId, method->head.context,
|
||||
&request->objectId, object->head.context);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
if(!executable) {
|
||||
@ -294,13 +294,13 @@ callWithMethodAndObject(UA_Server *server, UA_Session *session,
|
||||
UA_NODESTORE_RELEASE(server, (const UA_Node*)outputArguments);
|
||||
|
||||
/* Call the method */
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
result->statusCode = method->method(server, &session->sessionId, session->sessionHandle,
|
||||
&method->head.nodeId, method->head.context,
|
||||
&object->head.nodeId, object->head.context,
|
||||
request->inputArgumentsSize, request->inputArguments,
|
||||
result->outputArgumentsSize, result->outputArguments);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
/* TODO: Verify Output matches the argument definition */
|
||||
}
|
||||
|
||||
@ -421,7 +421,7 @@ Operation_CallMethod(UA_Server *server, UA_Session *session, void *context,
|
||||
void Service_Call(UA_Server *server, UA_Session *session,
|
||||
const UA_CallRequest *request, UA_CallResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing CallRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(server->config.maxNodesPerMethodCall != 0 &&
|
||||
request->methodsToCallSize > server->config.maxNodesPerMethodCall) {
|
||||
@ -440,9 +440,9 @@ UA_CallMethodResult
|
||||
UA_Server_call(UA_Server *server, const UA_CallMethodRequest *request) {
|
||||
UA_CallMethodResult result;
|
||||
UA_CallMethodResult_init(&result);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Operation_CallMethod(server, &server->adminSession, NULL, request, &result);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ checkAdjustMonitoredItemParams(UA_Server *server, UA_Session *session,
|
||||
const UA_MonitoredItem *mon,
|
||||
const UA_DataType* valueType,
|
||||
UA_MonitoringParameters *params) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Check the filter */
|
||||
if(mon->itemToMonitor.attributeId == UA_ATTRIBUTEID_EVENTNOTIFIER) {
|
||||
@ -245,7 +245,7 @@ Operation_CreateMonitoredItem(UA_Server *server, UA_Session *session,
|
||||
struct createMonContext *cmc,
|
||||
const UA_MonitoredItemCreateRequest *request,
|
||||
UA_MonitoredItemCreateResult *result) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Check available capacity */
|
||||
if(cmc->sub &&
|
||||
@ -398,7 +398,7 @@ Service_CreateMonitoredItems(UA_Server *server, UA_Session *session,
|
||||
UA_CreateMonitoredItemsResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing CreateMonitoredItemsRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(server->config.maxMonitoredItemsPerCall != 0 &&
|
||||
request->itemsToCreateSize > server->config.maxMonitoredItemsPerCall) {
|
||||
@ -444,9 +444,9 @@ UA_Server_createDataChangeMonitoredItem(UA_Server *server,
|
||||
|
||||
UA_MonitoredItemCreateResult result;
|
||||
UA_MonitoredItemCreateResult_init(&result);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Operation_CreateMonitoredItem(server, &server->adminSession, &cmc, &item, &result);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -511,7 +511,7 @@ Service_ModifyMonitoredItems(UA_Server *server, UA_Session *session,
|
||||
UA_ModifyMonitoredItemsResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing ModifyMonitoredItemsRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(server->config.maxMonitoredItemsPerCall != 0 &&
|
||||
request->itemsToModifySize > server->config.maxMonitoredItemsPerCall) {
|
||||
@ -614,7 +614,7 @@ Service_SetMonitoringMode(UA_Server *server, UA_Session *session,
|
||||
const UA_SetMonitoringModeRequest *request,
|
||||
UA_SetMonitoringModeResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing SetMonitoringMode");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(server->config.maxMonitoredItemsPerCall != 0 &&
|
||||
request->monitoredItemIdsSize > server->config.maxMonitoredItemsPerCall) {
|
||||
@ -643,7 +643,7 @@ Service_SetMonitoringMode(UA_Server *server, UA_Session *session,
|
||||
static void
|
||||
Operation_DeleteMonitoredItem(UA_Server *server, UA_Session *session, UA_Subscription *sub,
|
||||
const UA_UInt32 *monitoredItemId, UA_StatusCode *result) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
UA_MonitoredItem *mon = UA_Subscription_getMonitoredItem(sub, *monitoredItemId);
|
||||
if(!mon) {
|
||||
*result = UA_STATUSCODE_BADMONITOREDITEMIDINVALID;
|
||||
@ -658,7 +658,7 @@ Service_DeleteMonitoredItems(UA_Server *server, UA_Session *session,
|
||||
UA_DeleteMonitoredItemsResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing DeleteMonitoredItemsRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(server->config.maxMonitoredItemsPerCall != 0 &&
|
||||
request->monitoredItemIdsSize > server->config.maxMonitoredItemsPerCall) {
|
||||
@ -685,16 +685,16 @@ Service_DeleteMonitoredItems(UA_Server *server, UA_Session *session,
|
||||
|
||||
UA_StatusCode
|
||||
UA_Server_deleteMonitoredItem(UA_Server *server, UA_UInt32 monitoredItemId) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_MonitoredItem *mon, *mon_tmp;
|
||||
LIST_FOREACH_SAFE(mon, &server->localMonitoredItems, listEntry, mon_tmp) {
|
||||
if(mon->monitoredItemId != monitoredItemId)
|
||||
continue;
|
||||
UA_MonitoredItem_delete(server, mon);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_GOOD;
|
||||
}
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADMONITOREDITEMIDINVALID;
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,9 @@
|
||||
UA_StatusCode
|
||||
UA_Server_getNodeContext(UA_Server *server, UA_NodeId nodeId,
|
||||
void **nodeContext) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = getNodeContext(server, nodeId, nodeContext);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -68,10 +68,10 @@ editNodeContext(UA_Server *server, UA_Session* session,
|
||||
UA_StatusCode
|
||||
UA_Server_setNodeContext(UA_Server *server, UA_NodeId nodeId,
|
||||
void *nodeContext) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = UA_Server_editNode(server, &server->adminSession, &nodeId,
|
||||
(UA_EditNodeCallback)editNodeContext, nodeContext);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -566,7 +566,7 @@ copyChild(UA_Server *server, UA_Session *session,
|
||||
if(!server->config.nodeLifecycle.createOptionalChild)
|
||||
return UA_STATUSCODE_GOOD;
|
||||
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
UA_Boolean createChild =
|
||||
server->config.nodeLifecycle.createOptionalChild(server,
|
||||
&session->sessionId,
|
||||
@ -574,7 +574,7 @@ copyChild(UA_Server *server, UA_Session *session,
|
||||
&rd->nodeId.nodeId,
|
||||
destinationNodeId,
|
||||
&rd->referenceTypeId);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
if(!createChild)
|
||||
return UA_STATUSCODE_GOOD;
|
||||
}
|
||||
@ -610,12 +610,12 @@ copyChild(UA_Server *server, UA_Session *session,
|
||||
node->head.nodeId.namespaceIndex = destinationNodeId->namespaceIndex;
|
||||
|
||||
if (server->config.nodeLifecycle.generateChildNodeId) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
retval = server->config.nodeLifecycle.
|
||||
generateChildNodeId(server, &session->sessionId, session->sessionHandle,
|
||||
&rd->nodeId.nodeId, destinationNodeId,
|
||||
&rd->referenceTypeId, &node->head.nodeId);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
if(retval != UA_STATUSCODE_GOOD) {
|
||||
UA_NODESTORE_DELETE(server, node);
|
||||
return retval;
|
||||
@ -960,13 +960,13 @@ AddNode_raw(UA_Server *server, UA_Session *session, void *nodeContext,
|
||||
const UA_AddNodesItem *item, UA_NodeId *outNewNodeId) {
|
||||
/* Do not check access for server */
|
||||
if(session != &server->adminSession && server->config.accessControl.allowAddNode) {
|
||||
UA_UNLOCK(server->serviceMutex)
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
if (!server->config.accessControl.allowAddNode(server, &server->config.accessControl,
|
||||
&session->sessionId, session->sessionHandle, item)) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADUSERACCESSDENIED;
|
||||
}
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
/* Check the namespaceindex */
|
||||
@ -1280,11 +1280,11 @@ recursiveCallConstructors(UA_Server *server, UA_Session *session,
|
||||
/* Call the global constructor */
|
||||
void *context = head->context;
|
||||
if(server->config.nodeLifecycle.constructor) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
retval = server->config.nodeLifecycle.constructor(server, &session->sessionId,
|
||||
session->sessionHandle,
|
||||
&head->nodeId, &context);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
if(retval != UA_STATUSCODE_GOOD)
|
||||
return retval;
|
||||
}
|
||||
@ -1296,11 +1296,11 @@ recursiveCallConstructors(UA_Server *server, UA_Session *session,
|
||||
else if(type && head->nodeClass == UA_NODECLASS_VARIABLE)
|
||||
lifecycle = &type->variableTypeNode.lifecycle;
|
||||
if(lifecycle && lifecycle->constructor) {
|
||||
UA_UNLOCK(server->serviceMutex)
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
retval = lifecycle->constructor(server, &session->sessionId,
|
||||
session->sessionHandle, &type->head.nodeId,
|
||||
type->head.context, &head->nodeId, &context);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
if(retval != UA_STATUSCODE_GOOD)
|
||||
goto global_destructor;
|
||||
}
|
||||
@ -1317,20 +1317,20 @@ recursiveCallConstructors(UA_Server *server, UA_Session *session,
|
||||
/* Fail. Call the destructors. */
|
||||
local_destructor:
|
||||
if(lifecycle && lifecycle->destructor) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
lifecycle->destructor(server, &session->sessionId, session->sessionHandle,
|
||||
&type->head.nodeId, type->head.context, &head->nodeId,
|
||||
&context);
|
||||
UA_LOCK(server->serviceMutex)
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
global_destructor:
|
||||
if(server->config.nodeLifecycle.destructor) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
server->config.nodeLifecycle.destructor(server, &session->sessionId,
|
||||
session->sessionHandle,
|
||||
&head->nodeId, context);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -1529,7 +1529,7 @@ Service_AddNodes(UA_Server *server, UA_Session *session,
|
||||
const UA_AddNodesRequest *request,
|
||||
UA_AddNodesResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing AddNodesRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(server->config.maxNodesPerNodeManagement != 0 &&
|
||||
request->nodesToAddSize > server->config.maxNodesPerNodeManagement) {
|
||||
@ -1550,7 +1550,7 @@ addNode(UA_Server *server, const UA_NodeClass nodeClass, const UA_NodeId *reques
|
||||
const UA_QualifiedName browseName, const UA_NodeId *typeDefinition,
|
||||
const UA_NodeAttributes *attr, const UA_DataType *attributeType,
|
||||
void *nodeContext, UA_NodeId *outNewNodeId) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Create the AddNodesItem */
|
||||
UA_AddNodesItem item;
|
||||
@ -1585,12 +1585,12 @@ __UA_Server_addNode(UA_Server *server, const UA_NodeClass nodeClass,
|
||||
const UA_NodeAttributes *attr,
|
||||
const UA_DataType *attributeType,
|
||||
void *nodeContext, UA_NodeId *outNewNodeId) {
|
||||
UA_LOCK(server->serviceMutex)
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode reval =
|
||||
addNode(server, nodeClass, requestedNewNodeId, parentNodeId,
|
||||
referenceTypeId, browseName, typeDefinition, attr,
|
||||
attributeType, nodeContext, outNewNodeId);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return reval;
|
||||
}
|
||||
|
||||
@ -1610,19 +1610,19 @@ UA_Server_addNode_begin(UA_Server *server, const UA_NodeClass nodeClass,
|
||||
UA_ExtensionObject_setValueNoDelete(&item.nodeAttributes,
|
||||
(void*)(uintptr_t)attr, attributeType);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval =
|
||||
Operation_addNode_begin(server, &server->adminSession, nodeContext, &item,
|
||||
&parentNodeId, &referenceTypeId, outNewNodeId);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
UA_StatusCode
|
||||
UA_Server_addNode_finish(UA_Server *server, const UA_NodeId nodeId) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = AddNode_finish(server, &server->adminSession, &nodeId);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -1695,12 +1695,12 @@ recursiveDeconstructNode(UA_Server *server, UA_Session *session,
|
||||
else
|
||||
lifecycle = &type->variableTypeNode.lifecycle;
|
||||
if(lifecycle->destructor) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
lifecycle->destructor(server,
|
||||
&session->sessionId, session->sessionHandle,
|
||||
&type->head.nodeId, type->head.context,
|
||||
&head->nodeId, &context);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
UA_NODESTORE_RELEASE(server, type);
|
||||
}
|
||||
@ -1708,11 +1708,11 @@ recursiveDeconstructNode(UA_Server *server, UA_Session *session,
|
||||
|
||||
/* Call the global destructor */
|
||||
if(server->config.nodeLifecycle.destructor) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
server->config.nodeLifecycle.destructor(server, &session->sessionId,
|
||||
session->sessionHandle,
|
||||
&head->nodeId, context);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
/* Set the constructed flag to false */
|
||||
@ -1795,14 +1795,14 @@ deleteNodeOperation(UA_Server *server, UA_Session *session, void *context,
|
||||
const UA_DeleteNodesItem *item, UA_StatusCode *result) {
|
||||
/* Do not check access for server */
|
||||
if(session != &server->adminSession && server->config.accessControl.allowDeleteNode) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
if( !server->config.accessControl.allowDeleteNode(server, &server->config.accessControl,
|
||||
&session->sessionId, session->sessionHandle, item)) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
*result = UA_STATUSCODE_BADUSERACCESSDENIED;
|
||||
return;
|
||||
}
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
const UA_Node *node = UA_NODESTORE_GET(server, &item->nodeId);
|
||||
@ -1846,7 +1846,7 @@ Service_DeleteNodes(UA_Server *server, UA_Session *session,
|
||||
UA_DeleteNodesResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing DeleteNodesRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(server->config.maxNodesPerNodeManagement != 0 &&
|
||||
request->nodesToDeleteSize > server->config.maxNodesPerNodeManagement) {
|
||||
@ -1865,16 +1865,16 @@ Service_DeleteNodes(UA_Server *server, UA_Session *session,
|
||||
UA_StatusCode
|
||||
UA_Server_deleteNode(UA_Server *server, const UA_NodeId nodeId,
|
||||
UA_Boolean deleteReferences) {
|
||||
UA_LOCK(server->serviceMutex)
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = deleteNode(server, nodeId, deleteReferences);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
UA_StatusCode
|
||||
deleteNode(UA_Server *server, const UA_NodeId nodeId,
|
||||
UA_Boolean deleteReferences) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
UA_DeleteNodesItem item;
|
||||
item.deleteTargetReferences = deleteReferences;
|
||||
item.nodeId = nodeId;
|
||||
@ -1924,15 +1924,15 @@ Operation_addReference(UA_Server *server, UA_Session *session, void *context,
|
||||
|
||||
/* Check access rights */
|
||||
if(session != &server->adminSession && server->config.accessControl.allowAddReference) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
if (!server->config.accessControl.
|
||||
allowAddReference(server, &server->config.accessControl,
|
||||
&session->sessionId, session->sessionHandle, item)) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
*retval = UA_STATUSCODE_BADUSERACCESSDENIED;
|
||||
return;
|
||||
}
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
/* TODO: Currently no expandednodeids are allowed */
|
||||
@ -2031,7 +2031,7 @@ Service_AddReferences(UA_Server *server, UA_Session *session,
|
||||
UA_AddReferencesResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing AddReferencesRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
UA_assert(session);
|
||||
|
||||
if(server->config.maxNodesPerNodeManagement != 0 &&
|
||||
@ -2061,9 +2061,9 @@ UA_Server_addReference(UA_Server *server, const UA_NodeId sourceId,
|
||||
item.targetNodeId = targetId;
|
||||
|
||||
UA_StatusCode retval = UA_STATUSCODE_GOOD;
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Operation_addReference(server, &server->adminSession, NULL, &item, &retval);
|
||||
UA_UNLOCK(server->serviceMutex)
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -2076,15 +2076,15 @@ Operation_deleteReference(UA_Server *server, UA_Session *session, void *context,
|
||||
const UA_DeleteReferencesItem *item, UA_StatusCode *retval) {
|
||||
/* Do not check access for server */
|
||||
if(session != &server->adminSession && server->config.accessControl.allowDeleteReference) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
if (!server->config.accessControl.
|
||||
allowDeleteReference(server, &server->config.accessControl,
|
||||
&session->sessionId, session->sessionHandle, item)){
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
*retval = UA_STATUSCODE_BADUSERACCESSDENIED;
|
||||
return;
|
||||
}
|
||||
UA_LOCK(server->serviceMutex)
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
// TODO: Check consistency constraints, remove the references.
|
||||
@ -2115,7 +2115,7 @@ Service_DeleteReferences(UA_Server *server, UA_Session *session,
|
||||
UA_DeleteReferencesResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing DeleteReferencesRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(server->config.maxNodesPerNodeManagement != 0 &&
|
||||
request->referencesToDeleteSize > server->config.maxNodesPerNodeManagement) {
|
||||
@ -2144,9 +2144,9 @@ UA_Server_deleteReference(UA_Server *server, const UA_NodeId sourceNodeId,
|
||||
item.deleteBidirectional = deleteBidirectional;
|
||||
|
||||
UA_StatusCode retval = UA_STATUSCODE_GOOD;
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Operation_deleteReference(server, &server->adminSession, NULL, &item, &retval);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -2167,12 +2167,12 @@ UA_StatusCode
|
||||
UA_Server_setVariableNode_valueCallback(UA_Server *server,
|
||||
const UA_NodeId nodeId,
|
||||
const UA_ValueCallback callback) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = UA_Server_editNode(server, &server->adminSession, &nodeId,
|
||||
(UA_EditNodeCallback)setValueCallback,
|
||||
/* cast away const because callback uses const anyway */
|
||||
(UA_ValueCallback *)(uintptr_t) &callback);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -2203,7 +2203,7 @@ UA_Server_addDataSourceVariableNode(UA_Server *server, const UA_NodeId requested
|
||||
outNewNodeId = &newNodeId;
|
||||
}
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
/* Create the node and add it to the nodestore */
|
||||
UA_StatusCode retval = AddNode_raw(server, &server->adminSession, nodeContext,
|
||||
&item, outNewNodeId);
|
||||
@ -2225,7 +2225,7 @@ UA_Server_addDataSourceVariableNode(UA_Server *server, const UA_NodeId requested
|
||||
retval = AddNode_finish(server, &server->adminSession, outNewNodeId);
|
||||
|
||||
cleanup:
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
if(outNewNodeId == &newNodeId)
|
||||
UA_NodeId_clear(&newNodeId);
|
||||
|
||||
@ -2247,7 +2247,7 @@ setDataSource(UA_Server *server, UA_Session *session,
|
||||
UA_StatusCode
|
||||
setVariableNode_dataSource(UA_Server *server, const UA_NodeId nodeId,
|
||||
const UA_DataSource dataSource) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
return UA_Server_editNode(server, &server->adminSession, &nodeId,
|
||||
(UA_EditNodeCallback)setDataSource,
|
||||
/* casting away const because callback casts it back anyway */
|
||||
@ -2257,9 +2257,9 @@ setVariableNode_dataSource(UA_Server *server, const UA_NodeId nodeId,
|
||||
UA_StatusCode
|
||||
UA_Server_setVariableNode_dataSource(UA_Server *server, const UA_NodeId nodeId,
|
||||
const UA_DataSource dataSource) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = setVariableNode_dataSource(server, nodeId, dataSource);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -2286,7 +2286,7 @@ UA_StatusCode
|
||||
UA_Server_setVariableNode_valueBackend(UA_Server *server, const UA_NodeId nodeId,
|
||||
const UA_ValueBackend valueBackend){
|
||||
UA_StatusCode retval = UA_STATUSCODE_GOOD;
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
switch(valueBackend.backendType){
|
||||
case UA_VALUEBACKENDTYPE_NONE:
|
||||
return UA_STATUSCODE_BADCONFIGURATIONERROR;
|
||||
@ -2313,7 +2313,7 @@ UA_Server_setVariableNode_valueBackend(UA_Server *server, const UA_NodeId nodeId
|
||||
// (UA_ValueCallback *)(uintptr_t) &callback);
|
||||
|
||||
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -2445,11 +2445,11 @@ UA_Server_addMethodNode_finish(UA_Server *server, const UA_NodeId nodeId,
|
||||
UA_MethodCallback method,
|
||||
size_t inputArgumentsSize, const UA_Argument* inputArguments,
|
||||
size_t outputArgumentsSize, const UA_Argument* outputArguments) {
|
||||
UA_LOCK(server->serviceMutex)
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = UA_Server_addMethodNodeEx_finish(server, nodeId, method,
|
||||
inputArgumentsSize, inputArguments, UA_NODEID_NULL, NULL,
|
||||
outputArgumentsSize, outputArguments, UA_NODEID_NULL, NULL);
|
||||
UA_UNLOCK(server->serviceMutex)
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -2478,12 +2478,12 @@ UA_Server_addMethodNodeEx(UA_Server *server, const UA_NodeId requestedNewNodeId,
|
||||
UA_NodeId_init(&newId);
|
||||
outNewNodeId = &newId;
|
||||
}
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = Operation_addNode_begin(server, &server->adminSession,
|
||||
nodeContext, &item, &parentNodeId,
|
||||
&referenceTypeId, outNewNodeId);
|
||||
if(retval != UA_STATUSCODE_GOOD) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -2494,7 +2494,7 @@ UA_Server_addMethodNodeEx(UA_Server *server, const UA_NodeId requestedNewNodeId,
|
||||
outputArgumentsSize, outputArguments,
|
||||
outputArgumentsRequestedNewNodeId,
|
||||
outputArgumentsOutNewNodeId);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
if(outNewNodeId == &newId)
|
||||
UA_NodeId_clear(&newId);
|
||||
return retval;
|
||||
@ -2513,7 +2513,7 @@ UA_StatusCode
|
||||
setMethodNode_callback(UA_Server *server,
|
||||
const UA_NodeId methodNodeId,
|
||||
UA_MethodCallback methodCallback) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
return UA_Server_editNode(server, &server->adminSession, &methodNodeId,
|
||||
(UA_EditNodeCallback)editMethodCallback,
|
||||
(void*)(uintptr_t)methodCallback);
|
||||
@ -2523,9 +2523,9 @@ UA_StatusCode
|
||||
UA_Server_setMethodNode_callback(UA_Server *server,
|
||||
const UA_NodeId methodNodeId,
|
||||
UA_MethodCallback methodCallback) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retVal = setMethodNode_callback(server, methodNodeId, methodCallback);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@ -2557,10 +2557,10 @@ setNodeTypeLifecycle(UA_Server *server, UA_Session *session,
|
||||
UA_StatusCode
|
||||
UA_Server_setNodeTypeLifecycle(UA_Server *server, UA_NodeId nodeId,
|
||||
UA_NodeTypeLifecycle lifecycle) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = UA_Server_editNode(server, &server->adminSession, &nodeId,
|
||||
(UA_EditNodeCallback)setNodeTypeLifecycle,
|
||||
&lifecycle);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
@ -20,9 +20,9 @@
|
||||
/* Delayed callback to free the session memory */
|
||||
static void
|
||||
removeSessionCallback(UA_Server *server, session_list_entry *entry) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_Session_clear(&entry->session, server);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
void
|
||||
@ -30,7 +30,7 @@ UA_Server_removeSession(UA_Server *server, session_list_entry *sentry,
|
||||
UA_DiagnosticEvent event) {
|
||||
UA_Session *session = &sentry->session;
|
||||
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Remove the Subscriptions */
|
||||
#ifdef UA_ENABLE_SUBSCRIPTIONS
|
||||
@ -48,10 +48,10 @@ UA_Server_removeSession(UA_Server *server, session_list_entry *sentry,
|
||||
|
||||
/* Callback into userland access control */
|
||||
if(server->config.accessControl.closeSession) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
server->config.accessControl.closeSession(server, &server->config.accessControl,
|
||||
&session->sessionId, session->sessionHandle);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
/* Detach the Session from the SecureChannel */
|
||||
@ -100,7 +100,7 @@ UA_Server_removeSession(UA_Server *server, session_list_entry *sentry,
|
||||
UA_StatusCode
|
||||
UA_Server_removeSessionByToken(UA_Server *server, const UA_NodeId *token,
|
||||
UA_DiagnosticEvent event) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
session_list_entry *entry;
|
||||
LIST_FOREACH(entry, &server->sessions, pointers) {
|
||||
if(UA_NodeId_equal(&entry->session.header.authenticationToken, token)) {
|
||||
@ -113,7 +113,7 @@ UA_Server_removeSessionByToken(UA_Server *server, const UA_NodeId *token,
|
||||
|
||||
void
|
||||
UA_Server_cleanupSessions(UA_Server *server, UA_DateTime nowMonotonic) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
session_list_entry *sentry, *temp;
|
||||
LIST_FOREACH_SAFE(sentry, &server->sessions, pointers, temp) {
|
||||
/* Session has timed out? */
|
||||
@ -130,7 +130,7 @@ UA_Server_cleanupSessions(UA_Server *server, UA_DateTime nowMonotonic) {
|
||||
|
||||
UA_Session *
|
||||
getSessionByToken(UA_Server *server, const UA_NodeId *token) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
session_list_entry *current = NULL;
|
||||
LIST_FOREACH(current, &server->sessions, pointers) {
|
||||
@ -153,7 +153,7 @@ getSessionByToken(UA_Server *server, const UA_NodeId *token) {
|
||||
|
||||
UA_Session *
|
||||
UA_Server_getSessionById(UA_Server *server, const UA_NodeId *sessionId) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
session_list_entry *current = NULL;
|
||||
LIST_FOREACH(current, &server->sessions, pointers) {
|
||||
@ -217,7 +217,7 @@ signCreateSessionResponse(UA_Server *server, UA_SecureChannel *channel,
|
||||
UA_StatusCode
|
||||
UA_Server_createSession(UA_Server *server, UA_SecureChannel *channel,
|
||||
const UA_CreateSessionRequest *request, UA_Session **session) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(server->sessionCount >= server->config.maxSessions)
|
||||
return UA_STATUSCODE_BADTOOMANYSESSIONS;
|
||||
@ -251,7 +251,7 @@ void
|
||||
Service_CreateSession(UA_Server *server, UA_SecureChannel *channel,
|
||||
const UA_CreateSessionRequest *request,
|
||||
UA_CreateSessionResponse *response) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
UA_LOG_DEBUG_CHANNEL(&server->config.logger, channel, "Trying to create session");
|
||||
|
||||
if(channel->securityMode == UA_MESSAGESECURITYMODE_SIGN ||
|
||||
@ -561,7 +561,7 @@ Service_ActivateSession(UA_Server *server, UA_SecureChannel *channel,
|
||||
UA_ActivateSessionResponse *response) {
|
||||
const UA_EndpointDescription *ed = NULL;
|
||||
const UA_UserTokenPolicy *utp = NULL;
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
UA_Session *session = getSessionByToken(server, &request->requestHeader.authenticationToken);
|
||||
if(!session) {
|
||||
@ -731,7 +731,7 @@ void
|
||||
Service_CloseSession(UA_Server *server, UA_SecureChannel *channel,
|
||||
const UA_CloseSessionRequest *request,
|
||||
UA_CloseSessionResponse *response) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Part 4, 5.6.4: When the CloseSession Service is called before the Session
|
||||
* is successfully activated, the Server shall reject the request if the
|
||||
|
@ -29,7 +29,7 @@ setSubscriptionSettings(UA_Server *server, UA_Subscription *subscription,
|
||||
UA_UInt32 requestedMaxKeepAliveCount,
|
||||
UA_UInt32 maxNotificationsPerPublish,
|
||||
UA_Byte priority) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* re-parameterize the subscription */
|
||||
UA_BOUNDEDVALUE_SETWBOUNDS(server->config.publishingIntervalLimits,
|
||||
@ -54,7 +54,7 @@ void
|
||||
Service_CreateSubscription(UA_Server *server, UA_Session *session,
|
||||
const UA_CreateSubscriptionRequest *request,
|
||||
UA_CreateSubscriptionResponse *response) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Check limits for the number of subscriptions */
|
||||
if(((server->config.maxSubscriptions != 0) &&
|
||||
@ -119,7 +119,7 @@ Service_ModifySubscription(UA_Server *server, UA_Session *session,
|
||||
const UA_ModifySubscriptionRequest *request,
|
||||
UA_ModifySubscriptionResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing ModifySubscriptionRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
UA_Subscription *sub = UA_Session_getSubscriptionById(session, request->subscriptionId);
|
||||
if(!sub) {
|
||||
@ -154,7 +154,7 @@ static void
|
||||
Operation_SetPublishingMode(UA_Server *server, UA_Session *session,
|
||||
const UA_Boolean *publishingEnabled, const UA_UInt32 *subscriptionId,
|
||||
UA_StatusCode *result) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
UA_Subscription *sub = UA_Session_getSubscriptionById(session, *subscriptionId);
|
||||
if(!sub) {
|
||||
*result = UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID;
|
||||
@ -170,7 +170,7 @@ Service_SetPublishingMode(UA_Server *server, UA_Session *session,
|
||||
const UA_SetPublishingModeRequest *request,
|
||||
UA_SetPublishingModeResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing SetPublishingModeRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
UA_Boolean publishingEnabled = request->publishingEnabled; /* request is const */
|
||||
response->responseHeader.serviceResult =
|
||||
@ -184,7 +184,7 @@ void
|
||||
Service_Publish(UA_Server *server, UA_Session *session,
|
||||
const UA_PublishRequest *request, UA_UInt32 requestId) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing PublishRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Return an error if the session has no subscription */
|
||||
if(TAILQ_EMPTY(&session->subscriptions)) {
|
||||
@ -302,7 +302,7 @@ Service_DeleteSubscriptions(UA_Server *server, UA_Session *session,
|
||||
UA_DeleteSubscriptionsResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing DeleteSubscriptionsRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
response->responseHeader.serviceResult =
|
||||
UA_Server_processServiceOperations(server, session,
|
||||
@ -317,7 +317,7 @@ Service_Republish(UA_Server *server, UA_Session *session,
|
||||
UA_RepublishResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing RepublishRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Get the subscription */
|
||||
UA_Subscription *sub = UA_Session_getSubscriptionById(session, request->subscriptionId);
|
||||
@ -523,7 +523,7 @@ void Service_TransferSubscriptions(UA_Server *server, UA_Session *session,
|
||||
UA_TransferSubscriptionsResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing TransferSubscriptionsRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
response->responseHeader.serviceResult =
|
||||
UA_Server_processServiceOperations(server, session,
|
||||
|
@ -381,7 +381,7 @@ browseRecursive(UA_Server *server, size_t startNodesSize, const UA_NodeId *start
|
||||
UA_StatusCode
|
||||
UA_Server_browseRecursive(UA_Server *server, const UA_BrowseDescription *bd,
|
||||
size_t *resultsSize, UA_ExpandedNodeId **results) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
|
||||
/* Set the list of relevant reference types */
|
||||
UA_StatusCode retval = UA_STATUSCODE_GOOD;
|
||||
@ -391,7 +391,7 @@ UA_Server_browseRecursive(UA_Server *server, const UA_BrowseDescription *bd,
|
||||
retval = referenceTypeIndices(server, &bd->referenceTypeId,
|
||||
&refTypes, bd->includeSubtypes);
|
||||
if(retval != UA_STATUSCODE_GOOD) {
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
@ -400,7 +400,7 @@ UA_Server_browseRecursive(UA_Server *server, const UA_BrowseDescription *bd,
|
||||
retval = browseRecursive(server, 1, &bd->nodeId, bd->browseDirection,
|
||||
&refTypes, bd->nodeClassMask, false, resultsSize, results);
|
||||
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -777,7 +777,7 @@ Operation_Browse(UA_Server *server, UA_Session *session, const UA_UInt32 *maxref
|
||||
void Service_Browse(UA_Server *server, UA_Session *session,
|
||||
const UA_BrowseRequest *request, UA_BrowseResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session, "Processing BrowseRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Test the number of operations in the request */
|
||||
if(server->config.maxNodesPerBrowse != 0 &&
|
||||
@ -804,9 +804,9 @@ UA_Server_browse(UA_Server *server, UA_UInt32 maxReferences,
|
||||
const UA_BrowseDescription *bd) {
|
||||
UA_BrowseResult result;
|
||||
UA_BrowseResult_init(&result);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Operation_Browse(server, &server->adminSession, &maxReferences, bd, &result);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -858,7 +858,7 @@ Service_BrowseNext(UA_Server *server, UA_Session *session,
|
||||
UA_BrowseNextResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing BrowseNextRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
UA_Boolean releaseContinuationPoints = request->releaseContinuationPoints; /* request is const */
|
||||
response->responseHeader.serviceResult =
|
||||
@ -873,10 +873,10 @@ UA_Server_browseNext(UA_Server *server, UA_Boolean releaseContinuationPoint,
|
||||
const UA_ByteString *continuationPoint) {
|
||||
UA_BrowseResult result;
|
||||
UA_BrowseResult_init(&result);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Operation_BrowseNext(server, &server->adminSession, &releaseContinuationPoint,
|
||||
continuationPoint, &result);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1005,7 +1005,7 @@ Operation_TranslateBrowsePathToNodeIds(UA_Server *server, UA_Session *session,
|
||||
const UA_UInt32 *nodeClassMask,
|
||||
const UA_BrowsePath *path,
|
||||
UA_BrowsePathResult *result) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(path->relativePath.elementsSize <= 0) {
|
||||
result->statusCode = UA_STATUSCODE_BADNOTHINGTODO;
|
||||
@ -1122,7 +1122,7 @@ Operation_TranslateBrowsePathToNodeIds(UA_Server *server, UA_Session *session,
|
||||
UA_BrowsePathResult
|
||||
translateBrowsePathToNodeIds(UA_Server *server,
|
||||
const UA_BrowsePath *browsePath) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
UA_BrowsePathResult result;
|
||||
UA_BrowsePathResult_init(&result);
|
||||
UA_UInt32 nodeClassMask = 0; /* All node classes */
|
||||
@ -1134,9 +1134,9 @@ translateBrowsePathToNodeIds(UA_Server *server,
|
||||
UA_BrowsePathResult
|
||||
UA_Server_translateBrowsePathToNodeIds(UA_Server *server,
|
||||
const UA_BrowsePath *browsePath) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_BrowsePathResult result = translateBrowsePathToNodeIds(server, browsePath);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1146,7 +1146,7 @@ Service_TranslateBrowsePathsToNodeIds(UA_Server *server, UA_Session *session,
|
||||
UA_TranslateBrowsePathsToNodeIdsResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing TranslateBrowsePathsToNodeIdsRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Test the number of operations in the request */
|
||||
if(server->config.maxNodesPerTranslateBrowsePathsToNodeIds != 0 &&
|
||||
@ -1167,7 +1167,7 @@ Service_TranslateBrowsePathsToNodeIds(UA_Server *server, UA_Session *session,
|
||||
UA_BrowsePathResult
|
||||
browseSimplifiedBrowsePath(UA_Server *server, const UA_NodeId origin,
|
||||
size_t browsePathSize, const UA_QualifiedName *browsePath) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
UA_BrowsePathResult bpr;
|
||||
UA_BrowsePathResult_init(&bpr);
|
||||
@ -1206,9 +1206,9 @@ browseSimplifiedBrowsePath(UA_Server *server, const UA_NodeId origin,
|
||||
UA_BrowsePathResult
|
||||
UA_Server_browseSimplifiedBrowsePath(UA_Server *server, const UA_NodeId origin,
|
||||
size_t browsePathSize, const UA_QualifiedName *browsePath) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_BrowsePathResult bpr = browseSimplifiedBrowsePath(server, origin, browsePathSize, browsePath);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return bpr;
|
||||
}
|
||||
|
||||
@ -1221,7 +1221,7 @@ void Service_RegisterNodes(UA_Server *server, UA_Session *session,
|
||||
UA_RegisterNodesResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing RegisterNodesRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
//TODO: hang the nodeids to the session if really needed
|
||||
if(request->nodesToRegisterSize == 0) {
|
||||
@ -1248,7 +1248,7 @@ void Service_UnregisterNodes(UA_Server *server, UA_Session *session,
|
||||
UA_UnregisterNodesResponse *response) {
|
||||
UA_LOG_DEBUG_SESSION(&server->config.logger, session,
|
||||
"Processing UnRegisterNodesRequest");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
//TODO: remove the nodeids from the session if really needed
|
||||
if(request->nodesToUnregisterSize == 0)
|
||||
|
@ -25,7 +25,7 @@ void UA_Session_init(UA_Session *session) {
|
||||
}
|
||||
|
||||
void UA_Session_clear(UA_Session *session, UA_Server* server) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Remove all Subscriptions. This may send out remaining publish
|
||||
* responses. */
|
||||
|
@ -45,7 +45,7 @@ UA_Subscription_new() {
|
||||
|
||||
void
|
||||
UA_Subscription_delete(UA_Server *server, UA_Subscription *sub) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Unregister the publish callback */
|
||||
Subscription_unregisterPublishCallback(server, sub);
|
||||
@ -325,10 +325,10 @@ UA_Subscription_nextSequenceNumber(UA_UInt32 sequenceNumber) {
|
||||
|
||||
static void
|
||||
publishCallback(UA_Server *server, UA_Subscription *sub) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
sub->readyNotifications = sub->notificationQueueSize;
|
||||
UA_Subscription_publish(server, sub);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -385,7 +385,7 @@ sendStatusChangeDelete(UA_Server *server, UA_Subscription *sub,
|
||||
|
||||
void
|
||||
UA_Subscription_publish(UA_Server *server, UA_Subscription *sub) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
UA_LOG_DEBUG_SUBSCRIPTION(&server->config.logger, sub, "Publish Callback");
|
||||
UA_assert(sub);
|
||||
|
||||
@ -602,7 +602,7 @@ UA_StatusCode
|
||||
Subscription_registerPublishCallback(UA_Server *server, UA_Subscription *sub) {
|
||||
UA_LOG_DEBUG_SUBSCRIPTION(&server->config.logger, sub,
|
||||
"Register subscription publishing callback");
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(sub->publishCallbackId > 0)
|
||||
return UA_STATUSCODE_GOOD;
|
||||
|
@ -174,7 +174,7 @@ detectValueChangeWithFilter(UA_Server *server, UA_Session *session, UA_Monitored
|
||||
static UA_StatusCode
|
||||
detectValueChange(UA_Server *server, UA_Session *session, UA_MonitoredItem *mon,
|
||||
UA_DataValue value, UA_ByteString *encoding, UA_Boolean *changed) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Default trigger is statusvalue */
|
||||
UA_DataChangeTrigger trigger = UA_DATACHANGETRIGGER_STATUSVALUE;
|
||||
@ -285,12 +285,12 @@ sampleCallbackWithValue(UA_Server *server, UA_Session *session,
|
||||
UA_LocalMonitoredItem *localMon = (UA_LocalMonitoredItem*) mon;
|
||||
void *nodeContext = NULL;
|
||||
getNodeContext(server, mon->itemToMonitor.nodeId, &nodeContext);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
localMon->callback.dataChangeCallback(server,
|
||||
mon->monitoredItemId, localMon->context,
|
||||
&mon->itemToMonitor.nodeId, nodeContext,
|
||||
mon->itemToMonitor.attributeId, value);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
return UA_STATUSCODE_GOOD;
|
||||
@ -298,14 +298,14 @@ sampleCallbackWithValue(UA_Server *server, UA_Session *session,
|
||||
|
||||
void
|
||||
UA_MonitoredItem_sampleCallback(UA_Server *server, UA_MonitoredItem *monitoredItem) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
monitoredItem_sampleCallback(server, monitoredItem);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
void
|
||||
monitoredItem_sampleCallback(UA_Server *server, UA_MonitoredItem *monitoredItem) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
UA_Subscription *sub = monitoredItem->subscription;
|
||||
UA_Session *session = &server->adminSession;
|
||||
|
@ -30,12 +30,12 @@ UA_Event_generateEventId(UA_ByteString *generatedId) {
|
||||
UA_StatusCode
|
||||
UA_Server_createEvent(UA_Server *server, const UA_NodeId eventType,
|
||||
UA_NodeId *outNodeId) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
if(!outNodeId) {
|
||||
UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_USERLAND,
|
||||
"outNodeId must not be NULL. The event's NodeId must be returned "
|
||||
"so it can be triggered.");
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADINVALIDARGUMENT;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ UA_Server_createEvent(UA_Server *server, const UA_NodeId eventType,
|
||||
UA_REFERENCETYPEINDEX_HASSUBTYPE)) {
|
||||
UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_USERLAND,
|
||||
"Event type must be a subtype of BaseEventType!");
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADINVALIDARGUMENT;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ UA_Server_createEvent(UA_Server *server, const UA_NodeId eventType,
|
||||
UA_BrowsePathResult_clear(&bpr);
|
||||
deleteNode(server, newNodeId, true);
|
||||
UA_NodeId_clear(&newNodeId);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -93,12 +93,12 @@ UA_Server_createEvent(UA_Server *server, const UA_NodeId eventType,
|
||||
if(retval != UA_STATUSCODE_GOOD) {
|
||||
deleteNode(server, newNodeId, true);
|
||||
UA_NodeId_clear(&newNodeId);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
*outNodeId = newNodeId;
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_GOOD;
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ UA_StatusCode
|
||||
UA_Server_evaluateWhereClauseContentFilter(UA_Server *server,
|
||||
const UA_NodeId *eventNode,
|
||||
const UA_ContentFilter *contentFilter) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
if(contentFilter->elements == NULL || contentFilter->elementsSize == 0) {
|
||||
/* Nothing to do.*/
|
||||
@ -523,7 +523,7 @@ UA_StatusCode
|
||||
UA_Server_triggerEvent(UA_Server *server, const UA_NodeId eventNodeId,
|
||||
const UA_NodeId origin, UA_ByteString *outEventId,
|
||||
const UA_Boolean deleteEventNode) {
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
|
||||
UA_LOG_NODEID_DEBUG(&origin,
|
||||
UA_LOG_DEBUG(&server->config.logger, UA_LOGCATEGORY_SERVER,
|
||||
@ -537,7 +537,7 @@ UA_Server_triggerEvent(UA_Server *server, const UA_NodeId eventNodeId,
|
||||
UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
|
||||
"Condition Events: Please use A&C API to trigger Condition Events 0x%08X",
|
||||
UA_STATUSCODE_BADINVALIDARGUMENT);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADINVALIDARGUMENT;
|
||||
}
|
||||
}
|
||||
@ -548,7 +548,7 @@ UA_Server_triggerEvent(UA_Server *server, const UA_NodeId eventNodeId,
|
||||
if(!originNode) {
|
||||
UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_USERLAND,
|
||||
"Origin node for event does not exist.");
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADNOTFOUND;
|
||||
}
|
||||
UA_NODESTORE_RELEASE(server, originNode);
|
||||
@ -572,7 +572,7 @@ UA_Server_triggerEvent(UA_Server *server, const UA_NodeId eventNodeId,
|
||||
if(!isNodeInTree(server, &origin, &objectsFolderId, &refTypes)) {
|
||||
UA_LOG_ERROR(&server->config.logger, UA_LOGCATEGORY_USERLAND,
|
||||
"Node for event must be in ObjectsFolder!");
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return UA_STATUSCODE_BADINVALIDARGUMENT;
|
||||
}
|
||||
|
||||
@ -582,7 +582,7 @@ UA_Server_triggerEvent(UA_Server *server, const UA_NodeId eventNodeId,
|
||||
UA_LOG_WARNING(&server->config.logger, UA_LOGCATEGORY_SERVER,
|
||||
"Events: Could not set the standard event fields with StatusCode %s",
|
||||
UA_StatusCode_name(retval));
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -674,7 +674,7 @@ UA_Server_triggerEvent(UA_Server *server, const UA_NodeId eventNodeId,
|
||||
|
||||
cleanup:
|
||||
UA_Array_delete(emitNodes, emitNodesSize, &UA_TYPES[UA_TYPES_EXPANDEDNODEID]);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -400,12 +400,12 @@ UA_Server_registerMonitoredItem(UA_Server *server, UA_MonitoredItem *mon) {
|
||||
if(server->config.monitoredItemRegisterCallback) {
|
||||
void *targetContext = NULL;
|
||||
getNodeContext(server, mon->itemToMonitor.nodeId, &targetContext);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
server->config.monitoredItemRegisterCallback(server, &session->sessionId,
|
||||
session->sessionHandle,
|
||||
&mon->itemToMonitor.nodeId, targetContext,
|
||||
mon->itemToMonitor.attributeId, false);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
mon->registered = true;
|
||||
@ -427,13 +427,13 @@ UA_Server_unregisterMonitoredItem(UA_Server *server, UA_MonitoredItem *mon) {
|
||||
if(server->config.monitoredItemRegisterCallback) {
|
||||
void *targetContext = NULL;
|
||||
getNodeContext(server, mon->itemToMonitor.nodeId, &targetContext);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
server->config.monitoredItemRegisterCallback(server,
|
||||
session ? &session->sessionId : NULL,
|
||||
session ? session->sessionHandle : NULL,
|
||||
&mon->itemToMonitor.nodeId, targetContext,
|
||||
mon->itemToMonitor.attributeId, true);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
}
|
||||
|
||||
/* Remove from the node */
|
||||
@ -455,7 +455,7 @@ UA_Server_unregisterMonitoredItem(UA_Server *server, UA_MonitoredItem *mon) {
|
||||
|
||||
void
|
||||
UA_MonitoredItem_delete(UA_Server *server, UA_MonitoredItem *mon) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
|
||||
/* Deregister in Server and Subscription */
|
||||
if(mon->registered)
|
||||
@ -587,7 +587,7 @@ UA_MonitoredItem_ensureQueueSpace(UA_Server *server, UA_MonitoredItem *mon) {
|
||||
|
||||
UA_StatusCode
|
||||
UA_MonitoredItem_registerSampleCallback(UA_Server *server, UA_MonitoredItem *mon) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
if(mon->sampleCallbackIsRegistered)
|
||||
return UA_STATUSCODE_GOOD;
|
||||
|
||||
@ -605,7 +605,7 @@ UA_MonitoredItem_registerSampleCallback(UA_Server *server, UA_MonitoredItem *mon
|
||||
|
||||
void
|
||||
UA_MonitoredItem_unregisterSampleCallback(UA_Server *server, UA_MonitoredItem *mon) {
|
||||
UA_LOCK_ASSERT(server->serviceMutex, 1);
|
||||
UA_LOCK_ASSERT(&server->serviceMutex, 1);
|
||||
if(!mon->sampleCallbackIsRegistered)
|
||||
return;
|
||||
|
||||
|
@ -44,18 +44,18 @@ ZIP_IMPL(UA_TimerIdZip, UA_TimerEntry, idZipfields, UA_UInt64, id, cmpId)
|
||||
void
|
||||
UA_Timer_init(UA_Timer *t) {
|
||||
memset(t, 0, sizeof(UA_Timer));
|
||||
UA_LOCK_INIT(t->timerMutex)
|
||||
UA_LOCK_INIT(&t->timerMutex);
|
||||
}
|
||||
|
||||
void
|
||||
UA_Timer_addTimerEntry(UA_Timer *t, UA_TimerEntry *te, UA_UInt64 *callbackId) {
|
||||
UA_LOCK(t->timerMutex);
|
||||
UA_LOCK(&t->timerMutex);
|
||||
te->id = ++t->idCounter;
|
||||
if(callbackId)
|
||||
*callbackId = te->id;
|
||||
ZIP_INSERT(UA_TimerZip, &t->root, te, ZIP_FFS32(UA_UInt32_random()));
|
||||
ZIP_INSERT(UA_TimerIdZip, &t->idRoot, te, ZIP_RANK(te, zipfields));
|
||||
UA_UNLOCK(t->timerMutex);
|
||||
UA_UNLOCK(&t->timerMutex);
|
||||
}
|
||||
|
||||
static UA_StatusCode
|
||||
@ -91,9 +91,9 @@ UA_StatusCode
|
||||
UA_Timer_addTimedCallback(UA_Timer *t, UA_ApplicationCallback callback,
|
||||
void *application, void *data, UA_DateTime date,
|
||||
UA_UInt64 *callbackId) {
|
||||
UA_LOCK(t->timerMutex);
|
||||
UA_LOCK(&t->timerMutex);
|
||||
UA_StatusCode res = addCallback(t, callback, application, data, date, 0, callbackId);
|
||||
UA_UNLOCK(t->timerMutex);
|
||||
UA_UNLOCK(&t->timerMutex);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -113,10 +113,10 @@ UA_Timer_addRepeatedCallback(UA_Timer *t, UA_ApplicationCallback callback,
|
||||
return UA_STATUSCODE_BADINTERNALERROR;
|
||||
|
||||
UA_DateTime nextTime = UA_DateTime_nowMonotonic() + (UA_DateTime)interval;
|
||||
UA_LOCK(t->timerMutex);
|
||||
UA_LOCK(&t->timerMutex);
|
||||
UA_StatusCode res = addCallback(t, callback, application, data, nextTime,
|
||||
interval, callbackId);
|
||||
UA_UNLOCK(t->timerMutex);
|
||||
UA_UNLOCK(&t->timerMutex);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -127,12 +127,12 @@ UA_Timer_changeRepeatedCallbackInterval(UA_Timer *t, UA_UInt64 callbackId,
|
||||
if(interval_ms <= 0.0)
|
||||
return UA_STATUSCODE_BADINTERNALERROR;
|
||||
|
||||
UA_LOCK(t->timerMutex);
|
||||
UA_LOCK(&t->timerMutex);
|
||||
|
||||
/* Remove from the sorted list */
|
||||
UA_TimerEntry *te = ZIP_FIND(UA_TimerIdZip, &t->idRoot, &callbackId);
|
||||
if(!te) {
|
||||
UA_UNLOCK(t->timerMutex);
|
||||
UA_UNLOCK(&t->timerMutex);
|
||||
return UA_STATUSCODE_BADNOTFOUND;
|
||||
}
|
||||
|
||||
@ -142,30 +142,30 @@ UA_Timer_changeRepeatedCallbackInterval(UA_Timer *t, UA_UInt64 callbackId,
|
||||
te->nextTime = UA_DateTime_nowMonotonic() + (UA_DateTime)te->interval;
|
||||
ZIP_INSERT(UA_TimerZip, &t->root, te, ZIP_RANK(te, zipfields));
|
||||
|
||||
UA_UNLOCK(t->timerMutex);
|
||||
UA_UNLOCK(&t->timerMutex);
|
||||
return UA_STATUSCODE_GOOD;
|
||||
}
|
||||
|
||||
void
|
||||
UA_Timer_removeCallback(UA_Timer *t, UA_UInt64 callbackId) {
|
||||
UA_LOCK(t->timerMutex);
|
||||
UA_LOCK(&t->timerMutex);
|
||||
UA_TimerEntry *te = ZIP_FIND(UA_TimerIdZip, &t->idRoot, &callbackId);
|
||||
if(!te) {
|
||||
UA_UNLOCK(t->timerMutex);
|
||||
UA_UNLOCK(&t->timerMutex);
|
||||
return;
|
||||
}
|
||||
|
||||
ZIP_REMOVE(UA_TimerZip, &t->root, te);
|
||||
ZIP_REMOVE(UA_TimerIdZip, &t->idRoot, te);
|
||||
UA_free(te);
|
||||
UA_UNLOCK(t->timerMutex);
|
||||
UA_UNLOCK(&t->timerMutex);
|
||||
}
|
||||
|
||||
UA_DateTime
|
||||
UA_Timer_process(UA_Timer *t, UA_DateTime nowMonotonic,
|
||||
UA_TimerExecutionCallback executionCallback,
|
||||
void *executionApplication) {
|
||||
UA_LOCK(t->timerMutex);
|
||||
UA_LOCK(&t->timerMutex);
|
||||
UA_TimerEntry *first;
|
||||
while((first = ZIP_MIN(UA_TimerZip, &t->root)) &&
|
||||
first->nextTime <= nowMonotonic) {
|
||||
@ -178,10 +178,10 @@ UA_Timer_process(UA_Timer *t, UA_DateTime nowMonotonic,
|
||||
if(first->interval == 0) {
|
||||
ZIP_REMOVE(UA_TimerIdZip, &t->idRoot, first);
|
||||
if(first->callback) {
|
||||
UA_UNLOCK(t->timerMutex);
|
||||
UA_UNLOCK(&t->timerMutex);
|
||||
executionCallback(executionApplication, first->callback,
|
||||
first->application, first->data);
|
||||
UA_LOCK(t->timerMutex);
|
||||
UA_LOCK(&t->timerMutex);
|
||||
}
|
||||
UA_free(first);
|
||||
continue;
|
||||
@ -203,9 +203,9 @@ UA_Timer_process(UA_Timer *t, UA_DateTime nowMonotonic,
|
||||
UA_ApplicationCallback cb = first->callback;
|
||||
void *app = first->application;
|
||||
void *data = first->data;
|
||||
UA_UNLOCK(t->timerMutex);
|
||||
UA_UNLOCK(&t->timerMutex);
|
||||
executionCallback(executionApplication, cb, app, data);
|
||||
UA_LOCK(t->timerMutex);
|
||||
UA_LOCK(&t->timerMutex);
|
||||
}
|
||||
|
||||
/* Return the timestamp of the earliest next callback */
|
||||
@ -213,7 +213,7 @@ UA_Timer_process(UA_Timer *t, UA_DateTime nowMonotonic,
|
||||
UA_DateTime next = (first) ? first->nextTime : UA_INT64_MAX;
|
||||
if(next < nowMonotonic)
|
||||
next = nowMonotonic;
|
||||
UA_UNLOCK(t->timerMutex);
|
||||
UA_UNLOCK(&t->timerMutex);
|
||||
return next;
|
||||
}
|
||||
|
||||
@ -224,12 +224,12 @@ freeEntry(UA_TimerEntry *te, void *data) {
|
||||
|
||||
void
|
||||
UA_Timer_clear(UA_Timer *t) {
|
||||
UA_LOCK(t->timerMutex);
|
||||
UA_LOCK(&t->timerMutex);
|
||||
/* Free all nodes and reset the root */
|
||||
ZIP_ITER(UA_TimerZip, &t->root, freeEntry, NULL);
|
||||
UA_UNLOCK(t->timerMutex);
|
||||
UA_UNLOCK(&t->timerMutex);
|
||||
#if UA_MULTITHREADING >= 100
|
||||
UA_LOCK_DESTROY(t->timerMutex)
|
||||
UA_LOCK_DESTROY(&t->timerMutex);
|
||||
#endif
|
||||
ZIP_INIT(&t->root);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ typedef struct {
|
||||
UA_UInt64 idCounter; /* Generate unique identifiers. Identifiers are always
|
||||
* above zero. */
|
||||
#if UA_MULTITHREADING >= 100
|
||||
UA_LOCK_TYPE(timerMutex)
|
||||
UA_Lock timerMutex;
|
||||
#endif
|
||||
} UA_Timer;
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
UA_NodeId pumpTypeId = {1, UA_NODEIDTYPE_NUMERIC, {1001}};
|
||||
UA_Int32 temperature = 42;
|
||||
|
||||
UA_LOCK_TYPE(mu)
|
||||
UA_Lock mu;
|
||||
|
||||
static UA_StatusCode
|
||||
readTemperature(UA_Server *tmpServer,
|
||||
@ -30,9 +30,9 @@ readTemperature(UA_Server *tmpServer,
|
||||
const UA_NodeId *nodeId, void *nodeContext,
|
||||
UA_Boolean sourceTimeStamp, const UA_NumericRange *range,
|
||||
UA_DataValue *dataValue) {
|
||||
UA_LOCK(mu);
|
||||
UA_LOCK(&mu);
|
||||
UA_Variant_setScalarCopy(&dataValue->value, &temperature, &UA_TYPES[UA_TYPES_INT32]);
|
||||
UA_UNLOCK(mu);
|
||||
UA_UNLOCK(&mu);
|
||||
dataValue->hasValue = true;
|
||||
return UA_STATUSCODE_GOOD;
|
||||
}
|
||||
@ -42,9 +42,9 @@ writeTemperature(UA_Server *tmpServer,
|
||||
const UA_NodeId *sessionId, void *sessionContext,
|
||||
const UA_NodeId *nodeId, void *nodeContext,
|
||||
const UA_NumericRange *range, const UA_DataValue *data) {
|
||||
UA_LOCK(mu);
|
||||
UA_LOCK(&mu);
|
||||
temperature = *(UA_Int32 *) data->value.data;
|
||||
UA_UNLOCK(mu);
|
||||
UA_UNLOCK(&mu);
|
||||
return UA_STATUSCODE_GOOD;
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ void client_readValue(void *value) {
|
||||
|
||||
static
|
||||
void initTest(void) {
|
||||
UA_LOCK_INIT(mu);
|
||||
UA_LOCK_INIT(&mu);
|
||||
|
||||
initThreadContext(NUMBER_OF_READ_WORKERS + NUMBER_OF_WRITE_WORKERS + 1, NUMBER_OF_READ_CLIENTS + NUMBER_OF_WRITE_CLIENTS, NULL);
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
#include <check.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <open62541/plugin/pubsub_udp.h>
|
||||
#include <open62541/server_config_default.h>
|
||||
#include <open62541/server_pubsub.h>
|
||||
#include <open62541/plugin/log_stdout.h>
|
||||
|
||||
#include "ua_pubsub.h"
|
||||
#include <check.h>
|
||||
#include <assert.h>
|
||||
|
||||
static UA_Server *server = NULL;
|
||||
|
||||
|
@ -5,8 +5,6 @@
|
||||
* Copyright (c) 2017 - 2018 Fraunhofer IOSB (Author: Andreas Ebner)
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <open62541/plugin/pubsub_udp.h>
|
||||
#include <open62541/server_config_default.h>
|
||||
#include <open62541/server_pubsub.h>
|
||||
@ -16,6 +14,9 @@
|
||||
#include "check.h"
|
||||
#include "thread_wrapper.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
UA_Server *server = NULL;
|
||||
UA_Boolean running;
|
||||
THREAD_HANDLE server_thread;
|
||||
|
@ -1,15 +1,14 @@
|
||||
#include <check.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <open62541/plugin/pubsub_udp.h>
|
||||
#include <open62541/server_config_default.h>
|
||||
#include <open62541/server_pubsub.h>
|
||||
#include <open62541/plugin/log_stdout.h>
|
||||
|
||||
#include "testing_clock.h"
|
||||
|
||||
#include "ua_pubsub.h"
|
||||
|
||||
#include <check.h>
|
||||
#include <assert.h>
|
||||
|
||||
static UA_Server *server = NULL;
|
||||
|
||||
/* global variables to check PubSubStateChangeCallback */
|
||||
|
@ -305,9 +305,9 @@ requestHistory(UA_DateTime start,
|
||||
request.nodesToReadSize = 1;
|
||||
request.nodesToRead = valueId;
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_HistoryRead(server, &server->adminSession, &request, response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
UA_HistoryReadRequest_clear(&request);
|
||||
}
|
||||
|
||||
@ -499,9 +499,9 @@ deleteHistory(UA_DateTime start,
|
||||
|
||||
UA_HistoryUpdateResponse response;
|
||||
UA_HistoryUpdateResponse_init(&response);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_HistoryUpdate(server, &server->adminSession, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
UA_HistoryUpdateRequest_clear(&request);
|
||||
UA_StatusCode ret = UA_STATUSCODE_GOOD;
|
||||
if (response.responseHeader.serviceResult != UA_STATUSCODE_GOOD)
|
||||
@ -553,9 +553,9 @@ updateHistory(UA_PerformUpdateType updateType, UA_DateTime *updateData, UA_Statu
|
||||
|
||||
UA_HistoryUpdateResponse response;
|
||||
UA_HistoryUpdateResponse_init(&response);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_HistoryUpdate(server, &server->adminSession, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
UA_HistoryUpdateRequest_clear(&request);
|
||||
UA_StatusCode ret = UA_STATUSCODE_GOOD;
|
||||
if (response.responseHeader.serviceResult != UA_STATUSCODE_GOOD)
|
||||
|
@ -81,9 +81,9 @@ START_TEST(readSpeed) {
|
||||
/* Set the NodeId */
|
||||
rvi.nodeId = readNodeIds[i % READNODES];
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_Read(server, &server->adminSession, &request, &res);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
|
||||
UA_ReadResponse_clear(&res);
|
||||
}
|
||||
@ -161,9 +161,9 @@ START_TEST(readSpeedWithEncoding) {
|
||||
size_t offset = 0;
|
||||
retval |= UA_decodeBinary(&request_msg, &offset, &req, &UA_TYPES[UA_TYPES_READREQUEST], NULL);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_Read(server, &server->adminSession, &req, &res);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
|
||||
UA_Byte *rpos = response_msg.data;
|
||||
const UA_Byte *rend = &response_msg.data[response_msg.length];
|
||||
|
@ -33,9 +33,9 @@ createSession(void) {
|
||||
UA_CreateSessionRequest request;
|
||||
UA_CreateSessionRequest_init(&request);
|
||||
request.requestedSessionTimeout = UA_UINT32_MAX;
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
UA_StatusCode retval = UA_Server_createSession(server, NULL, &request, &session);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(retval, 0);
|
||||
}
|
||||
|
||||
@ -68,9 +68,9 @@ createSubscription(void) {
|
||||
UA_CreateSubscriptionResponse response;
|
||||
UA_CreateSubscriptionResponse_init(&response);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CreateSubscription(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
subscriptionId = response.subscriptionId;
|
||||
|
||||
@ -101,9 +101,9 @@ createMonitoredItem(void) {
|
||||
UA_CreateMonitoredItemsResponse response;
|
||||
UA_CreateMonitoredItemsResponse_init(&response);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CreateMonitoredItems(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(response.resultsSize, 1);
|
||||
ck_assert_uint_eq(response.results[0].statusCode, UA_STATUSCODE_GOOD);
|
||||
@ -123,9 +123,9 @@ START_TEST(Server_createSubscription) {
|
||||
|
||||
UA_CreateSubscriptionResponse response;
|
||||
UA_CreateSubscriptionResponse_init(&response);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CreateSubscription(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
subscriptionId = response.subscriptionId;
|
||||
|
||||
@ -151,9 +151,9 @@ START_TEST(Server_modifySubscription) {
|
||||
UA_ModifySubscriptionResponse response;
|
||||
UA_ModifySubscriptionResponse_init(&response);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_ModifySubscription(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
|
||||
UA_ModifySubscriptionResponse_clear(&response);
|
||||
@ -172,9 +172,9 @@ START_TEST(Server_setPublishingMode) {
|
||||
UA_SetPublishingModeResponse response;
|
||||
UA_SetPublishingModeResponse_init(&response);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_SetPublishingMode(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(response.resultsSize, 1);
|
||||
@ -195,9 +195,9 @@ START_TEST(Server_republish) {
|
||||
UA_RepublishResponse response;
|
||||
UA_RepublishResponse_init(&response);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_Republish(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_BADMESSAGENOTAVAILABLE);
|
||||
|
||||
UA_RepublishResponse_clear(&response);
|
||||
@ -214,9 +214,9 @@ START_TEST(Server_republish_invalid) {
|
||||
UA_RepublishResponse response;
|
||||
UA_RepublishResponse_init(&response);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_Republish(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_BADSUBSCRIPTIONIDINVALID);
|
||||
|
||||
UA_RepublishResponse_clear(&response);
|
||||
@ -235,9 +235,9 @@ START_TEST(Server_deleteSubscription) {
|
||||
UA_DeleteSubscriptionsResponse del_response;
|
||||
UA_DeleteSubscriptionsResponse_init(&del_response);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_DeleteSubscriptions(server, session, &del_request, &del_response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(del_response.resultsSize, 1);
|
||||
ck_assert_uint_eq(del_response.results[0], UA_STATUSCODE_GOOD);
|
||||
|
||||
@ -253,9 +253,9 @@ START_TEST(Server_publishCallback) {
|
||||
UA_CreateSubscriptionRequest_init(&request);
|
||||
request.publishingEnabled = true;
|
||||
UA_CreateSubscriptionResponse_init(&response);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CreateSubscription(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
UA_UInt32 subscriptionId1 = response.subscriptionId;
|
||||
UA_CreateSubscriptionResponse_clear(&response);
|
||||
@ -264,9 +264,9 @@ START_TEST(Server_publishCallback) {
|
||||
UA_CreateSubscriptionRequest_init(&request);
|
||||
request.publishingEnabled = true;
|
||||
UA_CreateSubscriptionResponse_init(&response);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CreateSubscription(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
UA_UInt32 subscriptionId2 = response.subscriptionId;
|
||||
UA_Double publishingInterval = response.revisedPublishingInterval;
|
||||
@ -298,9 +298,9 @@ START_TEST(Server_publishCallback) {
|
||||
UA_DeleteSubscriptionsResponse del_response;
|
||||
UA_DeleteSubscriptionsResponse_init(&del_response);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_DeleteSubscriptions(server, session, &del_request, &del_response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(del_response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(del_response.resultsSize, 2);
|
||||
ck_assert_uint_eq(del_response.results[0], UA_STATUSCODE_GOOD);
|
||||
@ -341,9 +341,9 @@ START_TEST(Server_modifyMonitoredItems) {
|
||||
UA_ModifyMonitoredItemsResponse response;
|
||||
UA_ModifyMonitoredItemsResponse_init(&response);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_ModifyMonitoredItems(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(response.resultsSize, 1);
|
||||
ck_assert_uint_eq(response.results[0].statusCode, UA_STATUSCODE_GOOD);
|
||||
@ -361,9 +361,9 @@ START_TEST(Server_overflow) {
|
||||
UA_CreateSubscriptionRequest_init(&createSubscriptionRequest);
|
||||
createSubscriptionRequest.publishingEnabled = true;
|
||||
UA_CreateSubscriptionResponse_init(&createSubscriptionResponse);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CreateSubscription(server, session, &createSubscriptionRequest, &createSubscriptionResponse);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(createSubscriptionResponse.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
UA_UInt32 localSubscriptionId = createSubscriptionResponse.subscriptionId;
|
||||
UA_Double publishingInterval = createSubscriptionResponse.revisedPublishingInterval;
|
||||
@ -395,9 +395,9 @@ START_TEST(Server_overflow) {
|
||||
UA_CreateMonitoredItemsResponse createMonitoredItemsResponse;
|
||||
UA_CreateMonitoredItemsResponse_init(&createMonitoredItemsResponse);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CreateMonitoredItems(server, session, &createMonitoredItemsRequest, &createMonitoredItemsResponse);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(createMonitoredItemsResponse.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(createMonitoredItemsResponse.resultsSize, 1);
|
||||
ck_assert_uint_eq(createMonitoredItemsResponse.results[0].statusCode, UA_STATUSCODE_GOOD);
|
||||
@ -467,10 +467,10 @@ START_TEST(Server_overflow) {
|
||||
UA_ModifyMonitoredItemsResponse modifyMonitoredItemsResponse;
|
||||
UA_ModifyMonitoredItemsResponse_init(&modifyMonitoredItemsResponse);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_ModifyMonitoredItems(server, session, &modifyMonitoredItemsRequest,
|
||||
&modifyMonitoredItemsResponse);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(modifyMonitoredItemsResponse.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(modifyMonitoredItemsResponse.resultsSize, 1);
|
||||
ck_assert_uint_eq(modifyMonitoredItemsResponse.results[0].statusCode, UA_STATUSCODE_GOOD);
|
||||
@ -499,10 +499,10 @@ START_TEST(Server_overflow) {
|
||||
|
||||
UA_ModifyMonitoredItemsResponse_init(&modifyMonitoredItemsResponse);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_ModifyMonitoredItems(server, session, &modifyMonitoredItemsRequest,
|
||||
&modifyMonitoredItemsResponse);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(modifyMonitoredItemsResponse.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(modifyMonitoredItemsResponse.resultsSize, 1);
|
||||
ck_assert_uint_eq(modifyMonitoredItemsResponse.results[0].statusCode, UA_STATUSCODE_GOOD);
|
||||
@ -530,10 +530,10 @@ START_TEST(Server_overflow) {
|
||||
|
||||
UA_ModifyMonitoredItemsResponse_init(&modifyMonitoredItemsResponse);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_ModifyMonitoredItems(server, session, &modifyMonitoredItemsRequest,
|
||||
&modifyMonitoredItemsResponse);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(modifyMonitoredItemsResponse.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(modifyMonitoredItemsResponse.resultsSize, 1);
|
||||
ck_assert_uint_eq(modifyMonitoredItemsResponse.results[0].statusCode, UA_STATUSCODE_GOOD);
|
||||
@ -557,10 +557,10 @@ START_TEST(Server_overflow) {
|
||||
UA_DeleteSubscriptionsResponse deleteSubscriptionsResponse;
|
||||
UA_DeleteSubscriptionsResponse_init(&deleteSubscriptionsResponse);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_DeleteSubscriptions(server, session, &deleteSubscriptionsRequest,
|
||||
&deleteSubscriptionsResponse);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(deleteSubscriptionsResponse.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(deleteSubscriptionsResponse.resultsSize, 1);
|
||||
ck_assert_uint_eq(deleteSubscriptionsResponse.results[0], UA_STATUSCODE_GOOD);
|
||||
@ -584,9 +584,9 @@ START_TEST(Server_setMonitoringMode) {
|
||||
UA_SetMonitoringModeResponse response;
|
||||
UA_SetMonitoringModeResponse_init(&response);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_SetMonitoringMode(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(response.resultsSize, 1);
|
||||
ck_assert_uint_eq(response.results[0], UA_STATUSCODE_GOOD);
|
||||
@ -608,9 +608,9 @@ START_TEST(Server_deleteMonitoredItems) {
|
||||
UA_DeleteMonitoredItemsResponse response;
|
||||
UA_DeleteMonitoredItemsResponse_init(&response);
|
||||
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_DeleteMonitoredItems(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(response.resultsSize, 1);
|
||||
ck_assert_uint_eq(response.results[0], UA_STATUSCODE_GOOD);
|
||||
@ -629,9 +629,9 @@ START_TEST(Server_lifeTimeCount) {
|
||||
request.requestedLifetimeCount = 3;
|
||||
request.requestedMaxKeepAliveCount = 1;
|
||||
UA_CreateSubscriptionResponse_init(&response);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CreateSubscription(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(response.revisedMaxKeepAliveCount, 1);
|
||||
ck_assert_uint_eq(response.revisedLifetimeCount, 3);
|
||||
@ -643,9 +643,9 @@ START_TEST(Server_lifeTimeCount) {
|
||||
request.requestedLifetimeCount = 4;
|
||||
request.requestedMaxKeepAliveCount = 2;
|
||||
UA_CreateSubscriptionResponse_init(&response);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CreateSubscription(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(response.revisedMaxKeepAliveCount, 2);
|
||||
/* revisedLifetimeCount is revised to 3*MaxKeepAliveCount == 3 */
|
||||
@ -678,9 +678,9 @@ START_TEST(Server_lifeTimeCount) {
|
||||
|
||||
UA_CreateMonitoredItemsResponse mresponse;
|
||||
UA_CreateMonitoredItemsResponse_init(&mresponse);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CreateMonitoredItems(server, session, &mrequest, &mresponse);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(mresponse.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(mresponse.resultsSize, 1);
|
||||
ck_assert_uint_eq(mresponse.results[0].statusCode, UA_STATUSCODE_GOOD);
|
||||
@ -794,9 +794,9 @@ START_TEST(Server_invalidPublishingInterval) {
|
||||
request.publishingEnabled = true;
|
||||
request.requestedPublishingInterval = -5.0; // Must be positive
|
||||
UA_CreateSubscriptionResponse_init(&response);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CreateSubscription(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert(response.revisedPublishingInterval ==
|
||||
server->config.publishingIntervalLimits.min);
|
||||
@ -834,9 +834,9 @@ START_TEST(Server_invalidSamplingInterval) {
|
||||
|
||||
UA_CreateMonitoredItemsResponse response;
|
||||
UA_CreateMonitoredItemsResponse_init(&response);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_CreateMonitoredItems(server, session, &request, &response);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
||||
ck_assert_uint_eq(response.resultsSize, 1);
|
||||
ck_assert_uint_eq(response.results[0].statusCode, UA_STATUSCODE_GOOD);
|
||||
|
@ -147,10 +147,10 @@ removeSubscription(void) {
|
||||
|
||||
UA_DeleteSubscriptionsResponse deleteSubscriptionsResponse;
|
||||
UA_DeleteSubscriptionsResponse_init(&deleteSubscriptionsResponse);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
Service_DeleteSubscriptions(server, &server->adminSession, &deleteSubscriptionsRequest,
|
||||
&deleteSubscriptionsResponse);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
UA_DeleteSubscriptionsResponse_clear(&deleteSubscriptionsResponse);
|
||||
}
|
||||
|
||||
@ -709,9 +709,9 @@ START_TEST(evaluateWhereClause) {
|
||||
UA_ContentFilter contentFilter;
|
||||
UA_ContentFilter_init(&contentFilter);
|
||||
/* Empty Filter */
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
retval = UA_Server_evaluateWhereClauseContentFilter(server, &eventNodeId, &contentFilter);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
|
||||
UA_ContentFilterElement contentFilterElement;
|
||||
UA_ContentFilterElement_init(&contentFilterElement);
|
||||
@ -720,21 +720,21 @@ START_TEST(evaluateWhereClause) {
|
||||
|
||||
/* Illegal filter operators */
|
||||
contentFilterElement.filterOperator = UA_FILTEROPERATOR_RELATEDTO;
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
retval = UA_Server_evaluateWhereClauseContentFilter(server, &eventNodeId, &contentFilter);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(retval, UA_STATUSCODE_BADEVENTFILTERINVALID);
|
||||
contentFilterElement.filterOperator = UA_FILTEROPERATOR_INVIEW;
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
retval = UA_Server_evaluateWhereClauseContentFilter(server, &eventNodeId, &contentFilter);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(retval, UA_STATUSCODE_BADEVENTFILTERINVALID);
|
||||
|
||||
/* No operand provided */
|
||||
contentFilterElement.filterOperator = UA_FILTEROPERATOR_OFTYPE;
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
retval = UA_Server_evaluateWhereClauseContentFilter(server, &eventNodeId, &contentFilter);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(retval, UA_STATUSCODE_BADFILTEROPERANDCOUNTMISMATCH);
|
||||
|
||||
UA_ExtensionObject filterOperandExObj;
|
||||
@ -748,24 +748,24 @@ START_TEST(evaluateWhereClause) {
|
||||
|
||||
/* Same type*/
|
||||
UA_Variant_setScalar(&literalOperand.value, &eventType, &UA_TYPES[UA_TYPES_NODEID]);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
retval = UA_Server_evaluateWhereClauseContentFilter(server, &eventNodeId, &contentFilter);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
|
||||
|
||||
/* Base type*/
|
||||
UA_NodeId nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_BASEEVENTTYPE);
|
||||
UA_Variant_setScalar(&literalOperand.value, &nodeId, &UA_TYPES[UA_TYPES_NODEID]);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
retval = UA_Server_evaluateWhereClauseContentFilter(server, &eventNodeId, &contentFilter);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD);
|
||||
|
||||
/* Other type*/
|
||||
nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_BASEMODELCHANGEEVENTTYPE);
|
||||
UA_LOCK(server->serviceMutex);
|
||||
UA_LOCK(&server->serviceMutex);
|
||||
retval = UA_Server_evaluateWhereClauseContentFilter(server, &eventNodeId, &contentFilter);
|
||||
UA_UNLOCK(server->serviceMutex);
|
||||
UA_UNLOCK(&server->serviceMutex);
|
||||
ck_assert_uint_eq(retval, UA_STATUSCODE_BADNOMATCH);
|
||||
}
|
||||
END_TEST
|
||||
|
Loading…
Reference in New Issue
Block a user