Commit be5acd1c authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

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

Fixes eFootball PES 2021 in game contents download. Signed-off-by: 's avatarPaul Gofman <pgofman@codeweavers.com> Signed-off-by: 's avatarHans Leidekker <hans@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 1c659954
...@@ -2931,6 +2931,7 @@ BOOL WINAPI WinHttpReadData( HINTERNET hrequest, LPVOID buffer, DWORD to_read, L ...@@ -2931,6 +2931,7 @@ BOOL WINAPI WinHttpReadData( HINTERNET hrequest, LPVOID buffer, DWORD to_read, L
{ {
DWORD ret; DWORD ret;
struct request *request; struct request *request;
BOOL async;
TRACE("%p, %p, %d, %p\n", hrequest, buffer, to_read, read); 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 ...@@ -2946,7 +2947,8 @@ BOOL WINAPI WinHttpReadData( HINTERNET hrequest, LPVOID buffer, DWORD to_read, L
return FALSE; 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; struct read_data *r;
...@@ -2962,12 +2964,13 @@ BOOL WINAPI WinHttpReadData( HINTERNET hrequest, LPVOID buffer, DWORD to_read, L ...@@ -2962,12 +2964,13 @@ BOOL WINAPI WinHttpReadData( HINTERNET hrequest, LPVOID buffer, DWORD to_read, L
release_object( &request->hdr ); release_object( &request->hdr );
free( r ); 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 ); release_object( &request->hdr );
SetLastError( ret ); 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 ) static DWORD write_data( struct request *request, const void *buffer, DWORD to_write, DWORD *written, BOOL async )
......
...@@ -615,6 +615,11 @@ static void test_async( void ) ...@@ -615,6 +615,11 @@ static void test_async( void )
WaitForSingleObject( info.wait, INFINITE ); 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__ ); setup_test( &info, winhttp_close_handle, __LINE__ );
WinHttpCloseHandle( req ); WinHttpCloseHandle( req );
WinHttpCloseHandle( con ); WinHttpCloseHandle( con );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment