winhttp: Execute WinHttpReadData() synchronously if the data is available.

Fixes eFootball PES 2021 in game contents download.

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2021-08-25 12:57:54 +03:00 committed by Alexandre Julliard
parent 1c659954df
commit be5acd1c07
2 changed files with 11 additions and 3 deletions

View File

@ -2931,6 +2931,7 @@ BOOL WINAPI WinHttpReadData( HINTERNET hrequest, LPVOID buffer, DWORD to_read, L
{
DWORD ret;
struct request *request;
BOOL async;
TRACE("%p, %p, %d, %p\n", hrequest, buffer, to_read, read);
@ -2946,7 +2947,8 @@ BOOL WINAPI WinHttpReadData( HINTERNET hrequest, LPVOID buffer, DWORD to_read, L
return FALSE;
}
if (request->connect->hdr.flags & WINHTTP_FLAG_ASYNC)
if ((async = request->connect->hdr.flags & WINHTTP_FLAG_ASYNC) && !end_of_read_data( request )
&& !query_data_ready( request ))
{
struct read_data *r;
@ -2962,12 +2964,13 @@ BOOL WINAPI WinHttpReadData( HINTERNET hrequest, LPVOID buffer, DWORD to_read, L
release_object( &request->hdr );
free( r );
}
else ret = ERROR_IO_PENDING;
}
else ret = read_data( request, buffer, to_read, read, FALSE );
else ret = read_data( request, buffer, to_read, read, async );
release_object( &request->hdr );
SetLastError( ret );
return !ret;
return !ret || ret == ERROR_IO_PENDING;
}
static DWORD write_data( struct request *request, const void *buffer, DWORD to_write, DWORD *written, BOOL async )

View File

@ -615,6 +615,11 @@ static void test_async( void )
WaitForSingleObject( info.wait, INFINITE );
ok(info.last_status == WINHTTP_CALLBACK_STATUS_READ_COMPLETE, "got status %#x.\n", status);
ok((err == ERROR_SUCCESS && info.last_thread_id == GetCurrentThreadId())
|| (err == ERROR_IO_PENDING && info.last_thread_id != GetCurrentThreadId()),
"Got unexpected thread %#x, err %#x.\n", info.last_thread_id, err);
setup_test( &info, winhttp_close_handle, __LINE__ );
WinHttpCloseHandle( req );
WinHttpCloseHandle( con );