Skip to content

Commit 34bbb1a

Browse files
author
Paul Gofman
committed
fixup! ntdll: Simulate async file read and IO cancellation to workaround AC:Odyssey out of order dialogues bug.
CW-Bug-Id: #21711
1 parent 9cf34c9 commit 34bbb1a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

dlls/ntdll/unix/file.c

+13
Original file line numberDiff line numberDiff line change
@@ -5648,6 +5648,7 @@ struct async_file_read_job
56485648
LONG cancelled;
56495649
struct list queue_entry;
56505650
struct async_file_read_job *next;
5651+
ULONG64 queue_time_mcs;
56515652
};
56525653

56535654

@@ -5668,7 +5669,9 @@ static void *async_file_read_thread(void *dummy)
56685669
ULONG buffer_length = 0;
56695670
void *buffer = NULL;
56705671
struct list *entry;
5672+
struct timespec ts;
56715673
NTSTATUS status;
5674+
ULONG64 delay;
56725675
ULONG total;
56735676
int result;
56745677

@@ -5719,6 +5722,13 @@ static void *async_file_read_thread(void *dummy)
57195722
break;
57205723
}
57215724

5725+
clock_gettime( CLOCK_MONOTONIC, &ts );
5726+
delay = ts.tv_sec * (ULONG64)1000000 + ts.tv_nsec / 1000 - job->queue_time_mcs;
5727+
if (delay < 1000)
5728+
usleep( 1000 - delay );
5729+
else
5730+
usleep( 50 );
5731+
57225732
total = result;
57235733
status = (total || !job->length) ? STATUS_SUCCESS : STATUS_END_OF_FILE;
57245734
done:
@@ -5779,6 +5789,7 @@ static NTSTATUS queue_async_file_read( HANDLE handle, int unix_handle, int needs
57795789
IO_STATUS_BLOCK *io, void *buffer, ULONG length, LARGE_INTEGER *offset )
57805790
{
57815791
struct async_file_read_job *job;
5792+
struct timespec ts;
57825793

57835794
pthread_once( &async_file_read_once, async_file_read_init );
57845795

@@ -5810,6 +5821,8 @@ static NTSTATUS queue_async_file_read( HANDLE handle, int unix_handle, int needs
58105821
job->offset = *offset;
58115822
job->thread_id = GetCurrentThreadId();
58125823
job->cancelled = 0;
5824+
clock_gettime( CLOCK_MONOTONIC, &ts );
5825+
job->queue_time_mcs = ts.tv_sec * (ULONG64)1000000 + ts.tv_nsec / 1000;
58135826

58145827
list_add_tail( &async_file_read_queue, &job->queue_entry );
58155828

0 commit comments

Comments
 (0)