Skip to content

Use context fields instead of thread_local to store error.#125

Merged
mayuki merged 2 commits into
mainfrom
feature/RemoveThreadLocal
May 1, 2025
Merged

Use context fields instead of thread_local to store error.#125
mayuki merged 2 commits into
mainfrom
feature/RemoveThreadLocal

Conversation

@mayuki

@mayuki mayuki commented May 1, 2025

Copy link
Copy Markdown
Member

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.

@mayuki mayuki requested a review from Copilot May 1, 2025 06:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mayuki mayuki merged commit d881d8a into main May 1, 2025
@mayuki mayuki deleted the feature/RemoveThreadLocal branch May 1, 2025 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants