orange-guo commented on code in PR #614:
URL: https://github.com/apache/guacamole-server/pull/614#discussion_r2384917606
##########
src/libguac/error.c:
##########
@@ -169,78 +169,21 @@ const char* guac_status_string(guac_status status) {
#ifdef HAVE_LIBPTHREAD
-/* PThread implementation of __guac_error */
+/* Thread-local implementation using __thread for optimal performance */
-static pthread_key_t __guac_error_key;
-static pthread_once_t __guac_error_key_init = PTHREAD_ONCE_INIT;
-
-static pthread_key_t __guac_error_message_key;
-static pthread_once_t __guac_error_message_key_init = PTHREAD_ONCE_INIT;
-
-static void __guac_mem_free_pointer(void* pointer) {
-
- /* Free memory allocated to status variable */
- guac_mem_free(pointer);
-
-}
-
-static void __guac_alloc_error_key() {
-
- /* Create key, destroy any allocated variable on thread exit */
- pthread_key_create(&__guac_error_key, __guac_mem_free_pointer);
-
-}
-
-static void __guac_alloc_error_message_key() {
-
- /* Create key, destroy any allocated variable on thread exit */
- pthread_key_create(&__guac_error_message_key, __guac_mem_free_pointer);
-
-}
+/*
+ * Simple __thread implementation for error handling.
+ * Uses static allocation to avoid memory management complexity.
+ */
+static __thread guac_status __guac_error_storage;
+static __thread const char* __guac_error_message_storage = NULL;
Review Comment:
Replaced __thread usage with our own guac_thread_local API to ensure broad
compiler compatibility while
maintaining thread-safety.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]