Use context fields instead of thread_local to store error.#125
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR removes the use of thread_local storage for error messages and instead uses context fields to store error data, improving compatibility on devices without TLS.
- Updated native method signatures and error handling to pass context fields.
- Adjusted test cases and helper methods to use the new API.
- Modified native bindings and build scripts to align with the updated error handling approach.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/YetAnotherHttpHandler.Test/NativeMethodsTest.cs | Updated test to acquire and release runtime handles and use context-based error retrieval. |
| src/YetAnotherHttpHandler/ThrowHelper.cs | Changed the signature of ThrowIfFailed to take context pointers and updated error retrieval accordingly. |
| src/YetAnotherHttpHandler/RequestContext.cs | Updated request completion to call the revised ThrowIfFailed with context parameters. |
| src/YetAnotherHttpHandler/NativeMethods.g.cs src/YetAnotherHttpHandler/NativeMethods.Uwp.g.cs |
Updated P/Invoke signatures for yaha_get_last_error to accept context fields instead of using thread_local. |
| src/YetAnotherHttpHandler/NativeHttpHandlerCore.cs | Updated multiple calls to ThrowIfFailed and error retrieval to pass context parameters. |
| native/yaha_native/src/context.rs | Changed runtime creation using Builder and added a last_error field in the request context. |
| native/yaha_native/src/binding.rs | Removed thread_local error handling and replaced it with context-based error management; adjusted various error-setting locations accordingly. |
| native/yaha_native/build.rs | Updated OS detection using environment variables for building Windows resources. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR changes to use context fields instead of thread_local to store error.
On devices such as Android, TLS may not be available, so we will reduce the use of TLS.