Is UA_Server_writeValue thread-safe in the latest release

22 views
Skip to first unread message

Brian Francis

unread,
Feb 13, 2025, 3:52:51 AMFeb 13
to open62541
"Connecting a Variable with a Physical Process - Updating variables manually" (https://www.open62541.org/doc/master/tutorial_server_datasource.html) states the following: ... when a new value arrives from the underlying process, we can just write into the variable

This and the code that follows it seems to suggest that "UA_Server_writeValue" is thread-safe and that this call can be make while the server is running.

Is UA_Server_writeValue thread-safe or is the following issue from 5+ years ago still applicable?




Rolf Kalbermatter

unread,
Feb 14, 2025, 9:08:21 AMFeb 14
to open62541
If you look in the source of the open62541 library, you can see that UA_Server_writeValue() in fact calls __UA_Server_write() which does lock (acquire) the mutex in the server session before attempting to access anything in the session, and releases it afterwards.

So yes it is thread safe, by protecting the server session from concurrent access, but you have to watch out to avoid mutual exclusions.

Op donderdag 13 februari 2025 om 09:52:51 UTC+1 schreef brianfr...@gmail.com:

Brian Francis

unread,
Feb 16, 2025, 6:18:45 AMFeb 16
to open62541
Thank you Rolf.  Really appreciate you taking the time to answer my question and provide additional information that will help me in the future as I learn more about open62541 and its features and capabilities.
Reply all
Reply to author
Forward
0 new messages