wininet: Separate ftp session destruction from closing connections.

This commit is contained in:
Hans Leidekker 2007-10-20 21:14:59 +02:00 committed by Alexandre Julliard
parent add663fdd2
commit c33a51eaf2
1 changed files with 32 additions and 18 deletions

View File

@ -123,6 +123,7 @@ static const WCHAR szNoAccount[] = {'n','o','a','c','c','o','u','n','t','\0'};
static void FTP_CloseFileTransferHandle(LPWININETHANDLEHEADER hdr); static void FTP_CloseFileTransferHandle(LPWININETHANDLEHEADER hdr);
static void FTP_CloseSessionHandle(LPWININETHANDLEHEADER hdr); static void FTP_CloseSessionHandle(LPWININETHANDLEHEADER hdr);
static void FTP_CloseConnection(LPWININETHANDLEHEADER hdr);
static void FTP_CloseFindNextHandle(LPWININETHANDLEHEADER hdr); static void FTP_CloseFindNextHandle(LPWININETHANDLEHEADER hdr);
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam, static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam,
INTERNET_STATUS_CALLBACK lpfnStatusCB, LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext); INTERNET_STATUS_CALLBACK lpfnStatusCB, LPWININETHANDLEHEADER hdr, DWORD_PTR dwContext);
@ -1895,10 +1896,7 @@ 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 lpwfs->hdr.close_connection = FTP_CloseConnection;
* 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;
@ -2823,24 +2821,19 @@ recv_end:
return (nRC != -1); return (nRC != -1);
} }
/*********************************************************************** /***********************************************************************
* FTP_CloseSessionHandle (internal) * FTP_CloseConnection (internal)
*
* Deallocate session handle
*
* RETURNS
* TRUE on success
* FALSE on failure
* *
* Close connections
*/ */
static void FTP_CloseSessionHandle(LPWININETHANDLEHEADER hdr) static void FTP_CloseConnection(LPWININETHANDLEHEADER hdr)
{ {
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) hdr; LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) hdr;
TRACE("\n"); TRACE("\n");
WININET_Release(&lpwfs->lpAppInfo->hdr); SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext,
INTERNET_STATUS_CLOSING_CONNECTION, 0, 0);
if (lpwfs->download_in_progress != NULL) if (lpwfs->download_in_progress != NULL)
lpwfs->download_in_progress->session_deleted = TRUE; lpwfs->download_in_progress->session_deleted = TRUE;
@ -2851,6 +2844,27 @@ static void FTP_CloseSessionHandle(LPWININETHANDLEHEADER hdr)
if (lpwfs->lstnSocket != -1) if (lpwfs->lstnSocket != -1)
closesocket(lpwfs->lstnSocket); closesocket(lpwfs->lstnSocket);
if (lpwfs->pasvSocket != -1)
closesocket(lpwfs->pasvSocket);
SendAsyncCallback(&lpwfs->hdr, lpwfs->hdr.dwContext,
INTERNET_STATUS_CONNECTION_CLOSED, 0, 0);
}
/***********************************************************************
* FTP_CloseSessionHandle (internal)
*
* Deallocate session handle
*/
static void FTP_CloseSessionHandle(LPWININETHANDLEHEADER hdr)
{
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) hdr;
TRACE("\n");
WININET_Release(&lpwfs->lpAppInfo->hdr);
HeapFree(GetProcessHeap(), 0, lpwfs->lpszPassword); HeapFree(GetProcessHeap(), 0, lpwfs->lpszPassword);
HeapFree(GetProcessHeap(), 0, lpwfs->lpszUserName); HeapFree(GetProcessHeap(), 0, lpwfs->lpszUserName);
HeapFree(GetProcessHeap(), 0, lpwfs); HeapFree(GetProcessHeap(), 0, lpwfs);