wininet: Separate connection closing from object destruction.

This commit is contained in:
Misha Koshelev 2007-08-23 00:06:00 -05:00 committed by Alexandre Julliard
parent 4b2f9af998
commit 0f117e568f
4 changed files with 19 additions and 4 deletions

View File

@ -1121,6 +1121,7 @@ HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs,
lpwh->hdr.dwFlags = dwFlags;
lpwh->hdr.dwContext = dwContext;
lpwh->hdr.dwRefCount = 1;
lpwh->hdr.close_connection = NULL;
lpwh->hdr.destroy = FTP_CloseFileTransferHandle;
lpwh->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB;
lpwh->nDataSocket = nDataSocket;
@ -1897,6 +1898,10 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
lpwfs->hdr.dwContext = dwContext;
lpwfs->hdr.dwInternalFlags = dwInternalFlags;
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.lpfnStatusCB = hIC->hdr.lpfnStatusCB;
lpwfs->download_in_progress = NULL;
@ -3006,6 +3011,7 @@ static HINTERNET FTP_ReceiveFileList(LPWININETFTPSESSIONW lpwfs, INT nSocket, LP
lpwfn->hdr.htype = WH_HFTPFINDNEXT;
lpwfn->hdr.dwContext = dwContext;
lpwfn->hdr.dwRefCount = 1;
lpwfn->hdr.close_connection = NULL;
lpwfn->hdr.destroy = FTP_CloseFindNextHandle;
lpwfn->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB;
lpwfn->index = 1; /* Next index is 1 since we return index 0 */

View File

@ -103,6 +103,7 @@ struct HttpAuthInfo
BOOL finished; /* finished authenticating */
};
static void HTTP_CloseConnection(LPWININETHANDLEHEADER hdr);
static void HTTP_CloseHTTPRequestHandle(LPWININETHANDLEHEADER hdr);
static void HTTP_CloseHTTPSessionHandle(LPWININETHANDLEHEADER hdr);
static BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr);
@ -1363,6 +1364,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
lpwhr->hdr.dwFlags = dwFlags;
lpwhr->hdr.dwContext = dwContext;
lpwhr->hdr.dwRefCount = 1;
lpwhr->hdr.close_connection = HTTP_CloseConnection;
lpwhr->hdr.destroy = HTTP_CloseHTTPRequestHandle;
lpwhr->hdr.lpfnStatusCB = lpwhs->hdr.lpfnStatusCB;
lpwhr->hdr.dwInternalFlags = lpwhs->hdr.dwInternalFlags & INET_CALLBACKW;
@ -2816,6 +2818,7 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
lpwhs->hdr.dwContext = dwContext;
lpwhs->hdr.dwInternalFlags = dwInternalFlags | (hIC->hdr.dwInternalFlags & INET_CALLBACKW);
lpwhs->hdr.dwRefCount = 1;
lpwhs->hdr.close_connection = NULL;
lpwhs->hdr.destroy = HTTP_CloseHTTPSessionHandle;
lpwhs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB;
@ -3319,8 +3322,9 @@ static BOOL HTTP_ProcessHeader(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR v
* Close socket connection
*
*/
static VOID HTTP_CloseConnection(LPWININETHTTPREQW lpwhr)
static void HTTP_CloseConnection(LPWININETHANDLEHEADER hdr)
{
LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) hdr;
LPWININETHTTPSESSIONW lpwhs = NULL;
LPWININETAPPINFOW hIC = NULL;
@ -3380,7 +3384,7 @@ BOOL HTTP_FinishedReading(LPWININETHTTPREQW lpwhr)
&dwBufferSize, NULL) ||
strcmpiW(szConnectionResponse, szKeepAlive))
{
HTTP_CloseConnection(lpwhr);
HTTP_CloseConnection(&lpwhr->hdr);
}
/* FIXME: store data in the URL cache here */
@ -3403,8 +3407,6 @@ static void HTTP_CloseHTTPRequestHandle(LPWININETHANDLEHEADER hdr)
WININET_Release(&lpwhr->lpHttpSession->hdr);
HTTP_CloseConnection(lpwhr);
HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath);
HeapFree(GetProcessHeap(), 0, lpwhr->lpszVerb);
HeapFree(GetProcessHeap(), 0, lpwhr->lpszRawHeaders);

View File

@ -173,6 +173,11 @@ BOOL WININET_Release( LPWININETHANDLEHEADER info )
TRACE( "object %p refcount = %d\n", info, 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);
info->destroy( info );
}
@ -477,6 +482,7 @@ HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
lpwai->hdr.htype = WH_HINIT;
lpwai->hdr.dwFlags = dwFlags;
lpwai->hdr.dwRefCount = 1;
lpwai->hdr.close_connection = NULL;
lpwai->hdr.destroy = INTERNET_CloseHandle;
lpwai->dwAccessType = dwAccessType;
lpwai->lpszProxyUsername = NULL;

View File

@ -146,6 +146,7 @@ struct _WININETHANDLEHEADER
DWORD dwError;
DWORD dwInternalFlags;
DWORD dwRefCount;
WININET_object_function close_connection;
WININET_object_function destroy;
INTERNET_STATUS_CALLBACK lpfnStatusCB;
};