Fix file descriptor assignment issues on Windows

This commit is contained in:
Justine Tunney 2024-09-15 22:16:38 -07:00
parent b73673e984
commit c3482af66d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2 changed files with 46 additions and 1 deletions

View file

@ -72,7 +72,7 @@ int __reservefd_unlocked(int start) {
if (_cmpxchg(&g_fds.p[fd].kind, kFdEmpty, kFdReserved)) {
// g_fds.f isn't guarded by our mutex
do {
f2 = MAX(fd + 1, f1);
f2 = MIN(fd + 1, f1);
} while (!atomic_compare_exchange_weak_explicit(
&g_fds.f, &f1, f2, memory_order_release, memory_order_relaxed));
return fd;