Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[open62541] Support UA_MULTITHREADING #42179

Open
reinder opened this issue Nov 15, 2024 · 6 comments · May be fixed by #43327
Open

[open62541] Support UA_MULTITHREADING #42179

reinder opened this issue Nov 15, 2024 · 6 comments · May be fixed by #43327
Assignees
Labels
category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist

Comments

@reinder
Copy link

reinder commented Nov 15, 2024

Is your feature request related to a problem? Please describe.

open65241 can be build with multi threading support, this allows multiple threads to call API functions of the SDK marked with UA_THREADSAFE-macro at the same time without causing race conditions. Furthermore, this level support the handling of asynchronous method calls from external worker threads.

See building.rst -> Build options -> Main build options -> UA_MULTITHREADING

Proposed solution

Add a feature multithreading to optionally enable multi threading support.

Describe alternatives you've considered

Using an overlay, but that will only fix it for me, not for everyone else.

Additional context

No response

@reinder reinder added the category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist label Nov 15, 2024
@Mengna-Li
Copy link
Contributor

I have tried it before, but it seems that UA_MULTITHREADING is not suitable to add as a feature. It is a variable and we cannot directly set it to 100 or 200 to turn on it.

UA_MULTITHREADING
Level of multi-threading support. The supported levels are currently as follows:
0-99: Multithreading support disabled.
>=100: API functions marked with the UA_THREADSAFE-macro are protected internally with mutexes. Multiple threads are allowed to call these functions of the SDK at the same time without causing race conditions. Furthermore, this level support the handling of asynchronous method calls from external worker threads.

@reinder
Copy link
Author

reinder commented Jan 16, 2025

@Mengna-Li thanks for your response.

I'm not familiar with the vcpkginternals, so correct me if I'm wrong.

Would it be an option to patch Open62541's CMakeLists.txt (vcpkg can perform patching I read) to add a boolean flag that sets the UA_MULTITHREADING variable to 100?

@Mengna-Li
Copy link
Contributor

You can add -DUA_MULTITHREADING = 100 as a option to vcpkg_cmake_configure in vcpkg/ports/open62541/portfile.cmake.

@reinder
Copy link
Author

reinder commented Jan 16, 2025

I just looked into the file, the multitheading option should works similar to the openssl mbedtls option, I going to give it a try.

@reinder
Copy link
Author

reinder commented Jan 16, 2025

I made a few changes, which should be enough I think, how can I test it locally?

0001-open62541-added-multithreading-feature.patch

@Mengna-Li
Copy link
Contributor

You just need to add the option -DUA_MULTITHREADING = 100 directly to the portfile.cmake file and use vcpkg install open62541 to install it normally, no patch is required.

vcpkg_cmake_configure(
     OPTIONS
         ${FEATURE_OPTIONS}
         ${OPEN62541_ENCRYPTION_OPTIONS}
         "-DOPEN62541_VERSION=v${VERSION}"
         -DUA_ENABLE_DEBUG_SANITIZER=OFF
         -DUA_MSVC_FORCE_STATIC_CRT=OFF
         -DUA_MULTITHREADING = 100
)

@reinder reinder linked a pull request Jan 17, 2025 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants