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

Fix locking in requests, os_unfair_lock not to be directly used in Swift #429

Merged
merged 1 commit into from
Jul 29, 2024

Conversation

julianlocke
Copy link
Contributor

@julianlocke julianlocke commented Jul 26, 2024

os_unfair_lock should not be used directly in Swift as it doesn't have a stable memory address, see https://developer.apple.com/documentation/os/osallocatedunfairlock. We can't yet use OSAllocatedUnfair lock due to our deployment target, but we can force os_unfair_lock to heap allocate and then use it safely.

Inspired by HA: https://github.com/home-assistant/HAKit/blob/main/Source/Internal/HAProtected.swift

@julianlocke julianlocke requested a review from jboulter11 July 26, 2024 22:05
@julianlocke julianlocke merged commit b16fc06 into master Jul 29, 2024
2 checks passed
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