Commit 0f117e56 authored by Misha Koshelev's avatar Misha Koshelev Committed by Alexandre Julliard

wininet: Separate connection closing from object destruction.

parent 4b2f9af9
...@@ -1121,6 +1121,7 @@ HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, ...@@ -1121,6 +1121,7 @@ HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs,
lpwh->hdr.dwFlags = dwFlags; lpwh->hdr.dwFlags = dwFlags;
lpwh->hdr.dwContext = dwContext; lpwh->hdr.dwContext = dwContext;
lpwh->hdr.dwRefCount = 1; lpwh->hdr.dwRefCount = 1;
lpwh->hdr.close_connection = NULL;
lpwh->hdr.destroy = FTP_CloseFileTransferHandle; lpwh->hdr.destroy = FTP_CloseFileTransferHandle;
lpwh->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB; lpwh->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB;
lpwh->nDataSocket = nDataSocket; lpwh->nDataSocket = nDataSocket;
...@@ -1897,6 +1898,10 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName, ...@@ -1897,6 +1898,10 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
lpwfs->hdr.dwContext = dwContext; lpwfs->hdr.dwContext = dwContext;
lpwfs->hdr.dwInternalFlags = dwInternalFlags; lpwfs->hdr.dwInternalFlags = dwInternalFlags;
lpwfs->hdr.dwRefCount = 1; lpwfs->hdr.dwRefCount = 1;
/* FIXME: Native sends INTERNET_STATUS_CLOSING_CONNECTION and
* INTERNET_STATUS_CONNECTION_CLOSED, need an equivalent FTP_CloseConnection
* function */
lpwfs->hdr.close_connection = NULL;
lpwfs->hdr.destroy = FTP_CloseSessionHandle; lpwfs->hdr.destroy = FTP_CloseSessionHandle;
lpwfs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB; lpwfs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB;
lpwfs->download_in_progress = NULL; lpwfs->download_in_progress = NULL;
...@@ -3006,6 +3011,7 @@ static HINTERNET FTP_ReceiveFileList(LPWININETFTPSESSIONW lpwfs, INT nSocket, LP ...@@ -3006,6 +3011,7 @@ static HINTERNET FTP_ReceiveFileList(LPWININETFTPSESSIONW lpwfs, INT nSocket, LP
lpwfn->hdr.htype = WH_HFTPFINDNEXT; lpwfn->hdr.htype = WH_HFTPFINDNEXT;
lpwfn->hdr.dwContext = dwContext; lpwfn->hdr.dwContext = dwContext;
lpwfn->hdr.dwRefCount = 1; lpwfn->hdr.dwRefCount = 1;
lpwfn->hdr.close_connection = NULL;
lpwfn->hdr.destroy = FTP_CloseFindNextHandle; lpwfn->hdr.destroy = FTP_CloseFindNextHandle;
lpwfn->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB; lpwfn->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB;
lpwfn->index = 1; /* Next index is 1 since we return index 0 */ lpwfn->index = 1; /* Next index is 1 since we return index 0 */
......
...@@ -103,6 +103,7 @@ struct HttpAuthInfo ...@@ -103,6 +103,7 @@ struct HttpAuthInfo
BOOL finished; /* finished authenticating */ BOOL finished; /* finished authenticating */
}; };
static void HTTP_CloseConnection(LPWININETHANDLEHEADER hdr);
static void HTTP_CloseHTTPRequestHandle(LPWININETHANDLEHEADER hdr); static void HTTP_CloseHTTPRequestHandle(LPWININETHANDLEHEADER hdr);
static void HTTP_CloseHTTPSessionHandle(LPWININETHANDLEHEADER hdr); static void HTTP_CloseHTTPSessionHandle(LPWININETHANDLEHEADER hdr);
static BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr); static BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr);
...@@ -1363,6 +1364,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, ...@@ -1363,6 +1364,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
lpwhr->hdr.dwFlags = dwFlags; lpwhr->hdr.dwFlags = dwFlags;
lpwhr->hdr.dwContext = dwContext; lpwhr->hdr.dwContext = dwContext;
lpwhr->hdr.dwRefCount = 1; lpwhr->hdr.dwRefCount = 1;
lpwhr->hdr.close_connection = HTTP_CloseConnection;
lpwhr->hdr.destroy = HTTP_CloseHTTPRequestHandle; lpwhr->hdr.destroy = HTTP_CloseHTTPRequestHandle;
lpwhr->hdr.lpfnStatusCB = lpwhs->hdr.lpfnStatusCB; lpwhr->hdr.lpfnStatusCB = lpwhs->hdr.lpfnStatusCB;
lpwhr->hdr.dwInternalFlags = lpwhs->hdr.dwInternalFlags & INET_CALLBACKW; lpwhr->hdr.dwInternalFlags = lpwhs->hdr.dwInternalFlags & INET_CALLBACKW;
...@@ -2816,6 +2818,7 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName, ...@@ -2816,6 +2818,7 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
lpwhs->hdr.dwContext = dwContext; lpwhs->hdr.dwContext = dwContext;
lpwhs->hdr.dwInternalFlags = dwInternalFlags | (hIC->hdr.dwInternalFlags & INET_CALLBACKW); lpwhs->hdr.dwInternalFlags = dwInternalFlags | (hIC->hdr.dwInternalFlags & INET_CALLBACKW);
lpwhs->hdr.dwRefCount = 1; lpwhs->hdr.dwRefCount = 1;
lpwhs->hdr.close_connection = NULL;
lpwhs->hdr.destroy = HTTP_CloseHTTPSessionHandle; lpwhs->hdr.destroy = HTTP_CloseHTTPSessionHandle;
lpwhs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB; lpwhs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB;
...@@ -3319,8 +3322,9 @@ static BOOL HTTP_ProcessHeader(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR v ...@@ -3319,8 +3322,9 @@ static BOOL HTTP_ProcessHeader(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR v
* Close socket connection * Close socket connection
* *
*/ */
static VOID HTTP_CloseConnection(LPWININETHTTPREQW lpwhr) static void HTTP_CloseConnection(LPWININETHANDLEHEADER hdr)
{ {
LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) hdr;
LPWININETHTTPSESSIONW lpwhs = NULL; LPWININETHTTPSESSIONW lpwhs = NULL;
LPWININETAPPINFOW hIC = NULL; LPWININETAPPINFOW hIC = NULL;
...@@ -3380,7 +3384,7 @@ BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr) ...@@ -3380,7 +3384,7 @@ BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr)
&dwBufferSize, NULL) || &dwBufferSize, NULL) ||
strcmpiW(szConnectionResponse, szKeepAlive)) strcmpiW(szConnectionResponse, szKeepAlive))
{ {
HTTP_CloseConnection(lpwhr); HTTP_CloseConnection(&lpwhr->hdr);
} }
/* FIXME: store data in the URL cache here */ /* FIXME: store data in the URL cache here */
...@@ -3403,8 +3407,6 @@ static void HTTP_CloseHTTPRequestHandle(LPWININETHANDLEHEADER hdr) ...@@ -3403,8 +3407,6 @@ static void HTTP_CloseHTTPRequestHandle(LPWININETHANDLEHEADER hdr)
WININET_Release(&lpwhr->lpHttpSession->hdr); WININET_Release(&lpwhr->lpHttpSession->hdr);
HTTP_CloseConnection(lpwhr);
HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath); HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath);
HeapFree(GetProcessHeap(), 0, lpwhr->lpszVerb); HeapFree(GetProcessHeap(), 0, lpwhr->lpszVerb);
HeapFree(GetProcessHeap(), 0, lpwhr->lpszRawHeaders); HeapFree(GetProcessHeap(), 0, lpwhr->lpszRawHeaders);
......
...@@ -173,6 +173,11 @@ BOOL WININET_Release( LPWININETHANDLEHEADER info ) ...@@ -173,6 +173,11 @@ BOOL WININET_Release( LPWININETHANDLEHEADER info )
TRACE( "object %p refcount = %d\n", info, info->dwRefCount ); TRACE( "object %p refcount = %d\n", info, info->dwRefCount );
if( !info->dwRefCount ) if( !info->dwRefCount )
{ {
if ( info->close_connection )
{
TRACE( "closing connection %p\n", info);
info->close_connection( info );
}
TRACE( "destroying object %p\n", info); TRACE( "destroying object %p\n", info);
info->destroy( info ); info->destroy( info );
} }
...@@ -477,6 +482,7 @@ HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, ...@@ -477,6 +482,7 @@ HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
lpwai->hdr.htype = WH_HINIT; lpwai->hdr.htype = WH_HINIT;
lpwai->hdr.dwFlags = dwFlags; lpwai->hdr.dwFlags = dwFlags;
lpwai->hdr.dwRefCount = 1; lpwai->hdr.dwRefCount = 1;
lpwai->hdr.close_connection = NULL;
lpwai->hdr.destroy = INTERNET_CloseHandle; lpwai->hdr.destroy = INTERNET_CloseHandle;
lpwai->dwAccessType = dwAccessType; lpwai->dwAccessType = dwAccessType;
lpwai->lpszProxyUsername = NULL; lpwai->lpszProxyUsername = NULL;
......
...@@ -146,6 +146,7 @@ struct _WININETHANDLEHEADER ...@@ -146,6 +146,7 @@ struct _WININETHANDLEHEADER
DWORD dwError; DWORD dwError;
DWORD dwInternalFlags; DWORD dwInternalFlags;
DWORD dwRefCount; DWORD dwRefCount;
WININET_object_function close_connection;
WININET_object_function destroy; WININET_object_function destroy;
INTERNET_STATUS_CALLBACK lpfnStatusCB; INTERNET_STATUS_CALLBACK lpfnStatusCB;
}; };
......
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