Signed-off-by: Paul Gofman pgofman@codeweavers.com --- v2: - added patch. It looks like those connection close notification are not sent at all starting from Win7 when the connection is auto closed (the modified test shows they were sent before Win7: https://testbot.winehq.org/JobDetails.pl?Key=100143).
dlls/winhttp/request.c | 10 ++++------ dlls/winhttp/tests/notification.c | 32 ++++++++----------------------- 2 files changed, 12 insertions(+), 30 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 2c064bb767b..c908e26956f 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -1797,13 +1797,11 @@ static void finished_reading( struct request *request ) if (!wcsicmp( connection, L"close" )) close = TRUE; } else if (!wcscmp( request->version, L"HTTP/1.0" )) close = TRUE; - if (close) - { - close_connection( request ); - return; - }
- cache_connection( request->netconn ); + if (close) + netconn_close( request->netconn ); + else + cache_connection( request->netconn ); request->netconn = NULL; }
diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c index bc1283adcf7..72cef89a618 100644 --- a/dlls/winhttp/tests/notification.c +++ b/dlls/winhttp/tests/notification.c @@ -1124,32 +1124,15 @@ static const struct notification read_test[] = { winhttp_read_data, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL } };
-static const struct notification read_allow_close_test[] = -{ - { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, NF_ALLOW }, - { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, NF_ALLOW }, - { winhttp_read_data, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, NF_ALLOW }, - { winhttp_read_data, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, NF_ALLOW }, - { winhttp_read_data, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL } -}; - -#define read_request_data(a,b,c,d) _read_request_data(a,b,c,d,__LINE__) -static void _read_request_data(struct test_request *req, struct info *info, const char *expected_data, BOOL closing_connection, unsigned line) +#define read_request_data(a,b,c) _read_request_data(a,b,c,__LINE__) +static void _read_request_data(struct test_request *req, struct info *info, const char *expected_data, unsigned line) { char buffer[1024]; DWORD len; BOOL ret;
- if (closing_connection) - { - info->test = read_allow_close_test; - info->count = ARRAY_SIZE( read_allow_close_test ); - } - else - { - info->test = read_test; - info->count = ARRAY_SIZE( read_test ); - } + info->test = read_test; + info->count = ARRAY_SIZE( read_test ); info->index = 0;
setup_test( info, winhttp_read_data, line ); @@ -1180,7 +1163,7 @@ static void test_persistent_connection(int port) "Content-Length: 1\r\n" "\r\n" "X" ); - read_request_data( &req, &info, "X", FALSE ); + read_request_data( &req, &info, "X" ); close_request( &req, &info, FALSE );
/* chunked connection test */ @@ -1194,7 +1177,7 @@ static void test_persistent_connection(int port) "\r\n" "9\r\n123456789\r\n" "0\r\n\r\n" ); - read_request_data( &req, &info, "123456789", FALSE ); + read_request_data( &req, &info, "123456789" ); close_request( &req, &info, FALSE );
/* HTTP/1.1 connections are persistent by default, no additional header is needed */ @@ -1206,7 +1189,7 @@ static void test_persistent_connection(int port) "Content-Length: 2\r\n" "\r\n" "xx" ); - read_request_data( &req, &info, "xx", FALSE ); + read_request_data( &req, &info, "xx" ); close_request( &req, &info, FALSE );
open_async_request( port, &req, &info, L"/test", TRUE ); @@ -1218,6 +1201,7 @@ static void test_persistent_connection(int port) "Connection: close\r\n" "\r\n" "yy" ); + read_request_data( &req, &info, "yy" ); close_request( &req, &info, TRUE );
SetEvent( server_socket_done );
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/winhttp/request.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index c908e26956f..d76edfa71d7 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -1848,6 +1848,7 @@ static DWORD read_data( struct request *request, void *buffer, DWORD size, DWORD
done: TRACE( "retrieved %u bytes (%u/%u)\n", bytes_read, request->content_read, request->content_length ); + if (end_of_read_data( request )) finished_reading( request ); if (async) { if (!ret) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, buffer, bytes_read ); @@ -1861,7 +1862,6 @@ done: }
if (!ret && read) *read = bytes_read; - if (end_of_read_data( request )) finished_reading( request ); return ret; }
Signed-off-by: Hans Leidekker hans@codeweavers.com
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=100153
Your paranoid android.
=== w8adm (32 bit report) ===
winhttp: notification.c:239: Test failed: failed to send request 12007 notification.c:241: Test failed: unexpected function 3, expected 4. probably some notifications were missing notification.c:243: Test failed: failed to receive response 12019 notification.c:247: Test failed: failed unexpectedly 12019 notification.c:248: Test failed: request failed unexpectedly 2147348480 notification.c:251: Test failed: unexpected function 3, expected 13. probably some notifications were missing notification.c:111: Test failed: 251: expected status 0x00000002 got 0x00000800 notification.c:112: Test failed: 251: expected function 3 got 13
=== w864 (64 bit report) ===
winhttp: notification.c:111: Test failed: 734: expected status 0x00000008 got 0x00200000
=== w1064v1507 (64 bit report) ===
winhttp: notification.c:111: Test failed: 734: expected status 0x00000008 got 0x00200000
=== w1064 (64 bit report) ===
winhttp: notification.c:111: Test failed: 734: expected status 0x00000008 got 0x00200000