Jacek Caban : wininet: Merge InternetReadFile and InternetReadFileEx implementations.
Alexandre Julliard
julliard at winehq.org
Fri Mar 10 16:51:43 CST 2017
Module: wine
Branch: master
Commit: 7eaadabc5cd9f77e358105e63ff9d8d9abaf7530
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7eaadabc5cd9f77e358105e63ff9d8d9abaf7530
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Mar 9 18:20:14 2017 +0100
wininet: Merge InternetReadFile and InternetReadFileEx implementations.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wininet/ftp.c | 12 ++----------
dlls/wininet/http.c | 38 +-------------------------------------
dlls/wininet/internet.c | 16 +++++++++-------
dlls/wininet/internet.h | 3 +--
dlls/wininet/tests/http.c | 2 --
5 files changed, 13 insertions(+), 58 deletions(-)
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index 396777d..e12e494 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -1184,7 +1184,8 @@ static DWORD FTPFILE_QueryOption(object_header_t *hdr, DWORD option, void *buffe
return INET_QueryOption(hdr, option, buffer, size, unicode);
}
-static DWORD FTPFILE_ReadFile(object_header_t *hdr, void *buffer, DWORD size, DWORD *read)
+static DWORD FTPFILE_ReadFile(object_header_t *hdr, void *buffer, DWORD size, DWORD *read,
+ DWORD flags, DWORD_PTR context)
{
ftp_file_t *file = (ftp_file_t*)hdr;
int res;
@@ -1208,12 +1209,6 @@ static DWORD FTPFILE_ReadFile(object_header_t *hdr, void *buffer, DWORD size, DW
return error;
}
-static DWORD FTPFILE_ReadFileEx(object_header_t *hdr, void *buf, DWORD size, DWORD *ret_size,
- DWORD flags, DWORD_PTR context)
-{
- return FTPFILE_ReadFile(hdr, buf, size, ret_size);
-}
-
static DWORD FTPFILE_WriteFile(object_header_t *hdr, const void *buffer, DWORD size, DWORD *written)
{
ftp_file_t *lpwh = (ftp_file_t*) hdr;
@@ -1300,7 +1295,6 @@ static const object_vtbl_t FTPFILEVtbl = {
FTPFILE_QueryOption,
INET_SetOption,
FTPFILE_ReadFile,
- FTPFILE_ReadFileEx,
FTPFILE_WriteFile,
FTPFILE_QueryDataAvailable,
NULL,
@@ -2404,7 +2398,6 @@ static const object_vtbl_t FTPSESSIONVtbl = {
NULL,
NULL,
NULL,
- NULL,
NULL
};
@@ -3543,7 +3536,6 @@ static const object_vtbl_t FTPFINDNEXTVtbl = {
NULL,
NULL,
NULL,
- NULL,
FTPFINDNEXT_FindNextFileW
};
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 3e0bd97..9cb517d 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -3163,7 +3163,7 @@ static DWORD async_read(http_request_t *req, void *buf, DWORD size, DWORD read_p
return ERROR_IO_PENDING;
}
-static DWORD HTTPREQ_ReadFileEx(object_header_t *hdr, void *buf, DWORD size, DWORD *ret_read,
+static DWORD HTTPREQ_ReadFile(object_header_t *hdr, void *buf, DWORD size, DWORD *ret_read,
DWORD flags, DWORD_PTR context)
{
http_request_t *req = (http_request_t*)hdr;
@@ -3251,40 +3251,6 @@ static DWORD HTTPREQ_WriteFile(object_header_t *hdr, const void *buffer, DWORD s
return res;
}
-static DWORD HTTPREQ_ReadFile(object_header_t *hdr, void *buffer, DWORD size, DWORD *read)
-{
- http_request_t *req = (http_request_t*)hdr;
- DWORD res;
-
- if (req->session->appInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC)
- {
- if (TryEnterCriticalSection( &req->read_section ))
- {
- if (get_avail_data(req) || end_of_read_data(req))
- {
- res = HTTPREQ_Read(req, buffer, size, read, BLOCKING_DISALLOW);
- LeaveCriticalSection( &req->read_section );
- return res;
- }
- LeaveCriticalSection( &req->read_section );
- }
-
- *read = 0;
- return async_read(req, buffer, size, 0, read);
- }
-
- EnterCriticalSection( &req->read_section );
- if(hdr->dwError == INTERNET_HANDLE_IN_USE)
- hdr->dwError = ERROR_INTERNET_INTERNAL_ERROR;
-
- res = HTTPREQ_Read(req, buffer, size, read, BLOCKING_WAITALL);
- if(res == ERROR_SUCCESS)
- res = hdr->dwError;
- LeaveCriticalSection( &req->read_section );
-
- return res;
-}
-
static DWORD HTTPREQ_QueryDataAvailable(object_header_t *hdr, DWORD *available, DWORD flags, DWORD_PTR ctx)
{
http_request_t *req = (http_request_t*)hdr;
@@ -3362,7 +3328,6 @@ static const object_vtbl_t HTTPREQVtbl = {
HTTPREQ_QueryOption,
HTTPREQ_SetOption,
HTTPREQ_ReadFile,
- HTTPREQ_ReadFileEx,
HTTPREQ_WriteFile,
HTTPREQ_QueryDataAvailable,
NULL,
@@ -5850,7 +5815,6 @@ static const object_vtbl_t HTTPSESSIONVtbl = {
NULL,
NULL,
NULL,
- NULL,
NULL
};
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 91678b6..1f1bbbd 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -982,7 +982,6 @@ static const object_vtbl_t APPINFOVtbl = {
APPINFO_SetOption,
NULL,
NULL,
- NULL,
NULL
};
@@ -2166,8 +2165,11 @@ BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
return FALSE;
}
- if(hdr->vtbl->ReadFile)
- res = hdr->vtbl->ReadFile(hdr, lpBuffer, dwNumOfBytesToRead, pdwNumOfBytesRead);
+ if(hdr->vtbl->ReadFile) {
+ res = hdr->vtbl->ReadFile(hdr, lpBuffer, dwNumOfBytesToRead, pdwNumOfBytesRead, 0, 0);
+ if(res == ERROR_IO_PENDING)
+ *pdwNumOfBytesRead = 0;
+ }
WININET_Release(hdr);
@@ -2225,8 +2227,8 @@ BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOu
return FALSE;
}
- if(hdr->vtbl->ReadFileEx)
- res = hdr->vtbl->ReadFileEx(hdr, lpBuffersOut->lpvBuffer, lpBuffersOut->dwBufferLength,
+ if(hdr->vtbl->ReadFile)
+ res = hdr->vtbl->ReadFile(hdr, lpBuffersOut->lpvBuffer, lpBuffersOut->dwBufferLength,
&lpBuffersOut->dwBufferLength, dwFlags, dwContext);
WININET_Release(hdr);
@@ -2263,8 +2265,8 @@ BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
return FALSE;
}
- if(hdr->vtbl->ReadFileEx)
- res = hdr->vtbl->ReadFileEx(hdr, lpBuffer->lpvBuffer, lpBuffer->dwBufferLength, &lpBuffer->dwBufferLength,
+ if(hdr->vtbl->ReadFile)
+ res = hdr->vtbl->ReadFile(hdr, lpBuffer->lpvBuffer, lpBuffer->dwBufferLength, &lpBuffer->dwBufferLength,
dwFlags, dwContext);
WININET_Release(hdr);
diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h
index d400df0..6a49bf1 100644
--- a/dlls/wininet/internet.h
+++ b/dlls/wininet/internet.h
@@ -279,8 +279,7 @@ typedef struct {
void (*CloseConnection)(object_header_t*);
DWORD (*QueryOption)(object_header_t*,DWORD,void*,DWORD*,BOOL);
DWORD (*SetOption)(object_header_t*,DWORD,void*,DWORD);
- DWORD (*ReadFile)(object_header_t*,void*,DWORD,DWORD*);
- DWORD (*ReadFileEx)(object_header_t*,void*,DWORD,DWORD*,DWORD,DWORD_PTR);
+ DWORD (*ReadFile)(object_header_t*,void*,DWORD,DWORD*,DWORD,DWORD_PTR);
DWORD (*WriteFile)(object_header_t*,const void*,DWORD,DWORD*);
DWORD (*QueryDataAvailable)(object_header_t*,DWORD*,DWORD,DWORD_PTR);
DWORD (*FindNextFileW)(object_header_t*,void*);
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 48adee6..3bb96e1 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -4520,7 +4520,6 @@ static void test_async_read(int port)
{
ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() );
ok( bytes == 0, "expected 0, got %u\n", bytes );
- todo_wine
CHECK_NOTIFIED( INTERNET_STATUS_RECEIVING_RESPONSE );
SET_EXPECT( INTERNET_STATUS_REQUEST_COMPLETE );
if (!pending_reads++)
@@ -4543,7 +4542,6 @@ static void test_async_read(int port)
if (!bytes) break;
}
- todo_wine
ok( pending_reads == 1, "expected 1 pending read, got %u\n", pending_reads );
ok( !strcmp(buffer, page1), "unexpected buffer content\n" );
close_async_handle( ses, hCompleteEvent, 2 );
More information about the wine-cvs
mailing list