Commit bdc81d99 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

wininet: Make the reference count of WININETHANDLEHEADER thread-safe by using…

wininet: Make the reference count of WININETHANDLEHEADER thread-safe by using InterlockedIncrement/InterlockedDecrement.
parent 8ffad443
......@@ -1296,7 +1296,7 @@ HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs,
lpwh->hdr.vtbl = &FTPFILEVtbl;
lpwh->hdr.dwFlags = dwFlags;
lpwh->hdr.dwContext = dwContext;
lpwh->hdr.dwRefCount = 1;
lpwh->hdr.refs = 1;
lpwh->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB;
lpwh->nDataSocket = nDataSocket;
lpwh->session_deleted = FALSE;
......@@ -2242,7 +2242,7 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
lpwfs->hdr.dwFlags = dwFlags;
lpwfs->hdr.dwContext = dwContext;
lpwfs->hdr.dwInternalFlags = dwInternalFlags;
lpwfs->hdr.dwRefCount = 1;
lpwfs->hdr.refs = 1;
lpwfs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB;
lpwfs->download_in_progress = NULL;
lpwfs->sndSocket = -1;
......@@ -3293,7 +3293,7 @@ static HINTERNET FTP_ReceiveFileList(LPWININETFTPSESSIONW lpwfs, INT nSocket, LP
lpwfn->hdr.htype = WH_HFTPFINDNEXT;
lpwfn->hdr.vtbl = &FTPFINDNEXTVtbl;
lpwfn->hdr.dwContext = dwContext;
lpwfn->hdr.dwRefCount = 1;
lpwfn->hdr.refs = 1;
lpwfn->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB;
lpwfn->index = 1; /* Next index is 1 since we return index 0 */
lpwfn->size = dwSize;
......
......@@ -1606,7 +1606,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
lpwhr->hdr.vtbl = &HTTPREQVtbl;
lpwhr->hdr.dwFlags = dwFlags;
lpwhr->hdr.dwContext = dwContext;
lpwhr->hdr.dwRefCount = 1;
lpwhr->hdr.refs = 1;
lpwhr->hdr.lpfnStatusCB = lpwhs->hdr.lpfnStatusCB;
lpwhr->hdr.dwInternalFlags = lpwhs->hdr.dwInternalFlags & INET_CALLBACKW;
......@@ -3159,7 +3159,7 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
lpwhs->hdr.dwFlags = dwFlags;
lpwhs->hdr.dwContext = dwContext;
lpwhs->hdr.dwInternalFlags = dwInternalFlags | (hIC->hdr.dwInternalFlags & INET_CALLBACKW);
lpwhs->hdr.dwRefCount = 1;
lpwhs->hdr.refs = 1;
lpwhs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB;
WININET_AddRef( &hIC->hdr );
......
......@@ -145,8 +145,8 @@ end:
LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info )
{
info->dwRefCount++;
TRACE("%p -> refcount = %d\n", info, info->dwRefCount );
ULONG refs = InterlockedIncrement(&info->refs);
TRACE("%p -> refcount = %d\n", info, refs );
return info;
}
......@@ -170,9 +170,9 @@ LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet )
BOOL WININET_Release( LPWININETHANDLEHEADER info )
{
info->dwRefCount--;
TRACE( "object %p refcount = %d\n", info, info->dwRefCount );
if( !info->dwRefCount )
ULONG refs = InterlockedDecrement(&info->refs);
TRACE( "object %p refcount = %d\n", info, refs );
if( !refs )
{
if ( info->vtbl->CloseConnection )
{
......@@ -537,7 +537,7 @@ HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
lpwai->hdr.htype = WH_HINIT;
lpwai->hdr.vtbl = &APPINFOVtbl;
lpwai->hdr.dwFlags = dwFlags;
lpwai->hdr.dwRefCount = 1;
lpwai->hdr.refs = 1;
lpwai->dwAccessType = dwAccessType;
lpwai->lpszProxyUsername = NULL;
lpwai->lpszProxyPassword = NULL;
......
......@@ -156,7 +156,7 @@ struct _WININETHANDLEHEADER
DWORD_PTR dwContext;
DWORD dwError;
DWORD dwInternalFlags;
DWORD dwRefCount;
LONG refs;
INTERNET_STATUS_CALLBACK lpfnStatusCB;
struct list entry;
struct list children;
......
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