Commit 1c659954 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

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

parent bc5305e5
...@@ -2873,6 +2873,7 @@ BOOL WINAPI WinHttpQueryDataAvailable( HINTERNET hrequest, LPDWORD available ) ...@@ -2873,6 +2873,7 @@ BOOL WINAPI WinHttpQueryDataAvailable( HINTERNET hrequest, LPDWORD available )
{ {
DWORD ret; DWORD ret;
struct request *request; struct request *request;
BOOL async;
TRACE("%p, %p\n", hrequest, available); TRACE("%p, %p\n", hrequest, available);
...@@ -2888,7 +2889,8 @@ BOOL WINAPI WinHttpQueryDataAvailable( HINTERNET hrequest, LPDWORD available ) ...@@ -2888,7 +2889,8 @@ BOOL WINAPI WinHttpQueryDataAvailable( HINTERNET hrequest, LPDWORD available )
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 query_data *q; struct query_data *q;
...@@ -2902,12 +2904,13 @@ BOOL WINAPI WinHttpQueryDataAvailable( HINTERNET hrequest, LPDWORD available ) ...@@ -2902,12 +2904,13 @@ BOOL WINAPI WinHttpQueryDataAvailable( HINTERNET hrequest, LPDWORD available )
release_object( &request->hdr ); release_object( &request->hdr );
free( q ); free( q );
} }
else ret = ERROR_IO_PENDING;
} }
else ret = query_data_available( request, available, FALSE ); else ret = query_data_available( request, available, async );
release_object( &request->hdr ); release_object( &request->hdr );
SetLastError( ret ); SetLastError( ret );
return !ret; return !ret || ret == ERROR_IO_PENDING;
} }
static void CALLBACK task_read_data( TP_CALLBACK_INSTANCE *instance, void *ctx, TP_WORK *work ) static void CALLBACK task_read_data( TP_CALLBACK_INSTANCE *instance, void *ctx, TP_WORK *work )
......
...@@ -71,6 +71,8 @@ struct info ...@@ -71,6 +71,8 @@ struct info
unsigned int index; unsigned int index;
HANDLE wait; HANDLE wait;
unsigned int line; unsigned int line;
DWORD last_thread_id;
DWORD last_status;
}; };
struct test_request struct test_request
...@@ -85,6 +87,9 @@ static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DW ...@@ -85,6 +87,9 @@ static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DW
BOOL status_ok, function_ok; BOOL status_ok, function_ok;
struct info *info = (struct info *)context; struct info *info = (struct info *)context;
info->last_status = status;
info->last_thread_id = GetCurrentThreadId();
if (status == WINHTTP_CALLBACK_STATUS_HANDLE_CREATED) if (status == WINHTTP_CALLBACK_STATUS_HANDLE_CREATED)
{ {
DWORD size = sizeof(struct info *); DWORD size = sizeof(struct info *);
...@@ -177,6 +182,8 @@ static void setup_test( struct info *info, enum api function, unsigned int line ...@@ -177,6 +182,8 @@ static void setup_test( struct info *info, enum api function, unsigned int line
ok_(__FILE__,line)(info->test[info->index].function == function, ok_(__FILE__,line)(info->test[info->index].function == function,
"unexpected function %u, expected %u. probably some notifications were missing\n", "unexpected function %u, expected %u. probably some notifications were missing\n",
info->test[info->index].function, function); info->test[info->index].function, function);
info->last_thread_id = 0xdeadbeef;
info->last_status = 0xdeadbeef;
} }
static void end_test( struct info *info, unsigned int line ) static void end_test( struct info *info, unsigned int line )
...@@ -597,6 +604,10 @@ static void test_async( void ) ...@@ -597,6 +604,10 @@ static void test_async( void )
ok(err == ERROR_SUCCESS || err == ERROR_IO_PENDING || broken(err == 0xdeadbeef) /* < win7 */, "got %u\n", err); ok(err == ERROR_SUCCESS || err == ERROR_IO_PENDING || broken(err == 0xdeadbeef) /* < win7 */, "got %u\n", err);
WaitForSingleObject( info.wait, INFINITE ); WaitForSingleObject( info.wait, INFINITE );
ok(info.last_status == WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE, "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_read_data, __LINE__ ); setup_test( &info, winhttp_read_data, __LINE__ );
ret = WinHttpReadData( req, buffer, sizeof(buffer), NULL ); ret = WinHttpReadData( req, buffer, sizeof(buffer), NULL );
......
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