@@ -124,14 +124,19 @@ BOOL SetEvent(HANDLE h)
124
124
}
125
125
}
126
126
127
- DWORD WaitForSingleObject (HANDLE h, DWORD ms)
127
+ DWORD WaitForSingleObject (const HANDLE h, const DWORD ms)
128
128
{
129
129
int fd = _handleToFD (h);
130
130
bool manualReset = _handleToFlags (h) & CREATE_EVENT_MANUAL_RESET;
131
131
pollfd pfd{fd, POLLIN, 0 };
132
132
uint64_t x;
133
133
int r = 0 ;
134
- int nEvents = poll (&pfd, 1 , ms);
134
+ // Implement unlimited waits as timing out with WAIT_FAILED after 5
135
+ // seconds. It's probably something fishy with d3dvk-proton or our synchapi
136
+ // implementation
137
+ const bool isInfinite = ms == INFINITE;
138
+ const DWORD fiveSeconds = 5000 ;
139
+ int nEvents = poll (&pfd, 1 , isInfinite ? fiveSeconds : ms);
135
140
if (pfd.revents != POLLIN)
136
141
{
137
142
return WAIT_FAILED;
@@ -142,7 +147,7 @@ DWORD WaitForSingleObject(HANDLE h, DWORD ms)
142
147
}
143
148
if (nEvents == 0 )
144
149
{
145
- return WAIT_TIMEOUT;
150
+ return isInfinite ? WAIT_FAILED : WAIT_TIMEOUT;
146
151
}
147
152
if (manualReset)
148
153
{
@@ -155,7 +160,7 @@ DWORD WaitForSingleObject(HANDLE h, DWORD ms)
155
160
}
156
161
if (r == -1 && errno == EAGAIN)
157
162
{
158
- return WAIT_TIMEOUT;
163
+ return isInfinite ? WAIT_FAILED : WAIT_TIMEOUT;
159
164
}
160
165
return WAIT_FAILED;
161
166
}
@@ -164,12 +169,19 @@ DWORD WaitForMultipleObjects(
164
169
DWORD n,
165
170
const HANDLE *hs,
166
171
BOOL bWaitAll,
167
- DWORD dwMilliseconds )
172
+ DWORD requestedMs )
168
173
{
169
174
if (n == 0 )
170
175
{
171
176
return bWaitAll ? WAIT_OBJECT_0 : WAIT_FAILED;
172
177
}
178
+
179
+ // Bail out of infinite waits after 5 seconds as it's probably a
180
+ // driver/vkd3d-proton/synchapi bug
181
+ const bool isInfinite = requestedMs == INFINITE;
182
+ const DWORD fiveSeconds = 5000 ;
183
+ const auto dwMilliseconds = isInfinite ? fiveSeconds : requestedMs;
184
+
173
185
DWORD res;
174
186
int fds[n];
175
187
int flagss[n];
@@ -281,7 +293,7 @@ DWORD WaitForMultipleObjects(
281
293
// If we got here without seeing enough events, we must have timed out
282
294
if (nSeenEvents < n)
283
295
{
284
- res = WAIT_TIMEOUT;
296
+ res = isInfinite ? WAIT_FAILED : WAIT_TIMEOUT;
285
297
goto end;
286
298
}
287
299
@@ -415,7 +427,7 @@ DWORD WaitForMultipleObjects(
415
427
}
416
428
if (nEvents == 0 )
417
429
{
418
- res = WAIT_TIMEOUT;
430
+ res = isInfinite ? WAIT_FAILED : WAIT_TIMEOUT;
419
431
goto end;
420
432
}
421
433
// Try reads until we get one
0 commit comments