wininet: Make the reference count of WININETHANDLEHEADER thread-safe by using InterlockedIncrement/InterlockedDecrement.

This commit is contained in:
Rob Shearman 2008-03-10 16:39:15 +00:00 committed by Alexandre Julliard
parent 8ffad44397
commit bdc81d9963
4 changed files with 12 additions and 12 deletions

View File

@ -1296,7 +1296,7 @@ HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs,
lpwh->hdr.vtbl = &FTPFILEVtbl; lpwh->hdr.vtbl = &FTPFILEVtbl;
lpwh->hdr.dwFlags = dwFlags; lpwh->hdr.dwFlags = dwFlags;
lpwh->hdr.dwContext = dwContext; lpwh->hdr.dwContext = dwContext;
lpwh->hdr.dwRefCount = 1; lpwh->hdr.refs = 1;
lpwh->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB; lpwh->hdr.lpfnStatusCB = lpwfs->hdr.lpfnStatusCB;
lpwh->nDataSocket = nDataSocket; lpwh->nDataSocket = nDataSocket;
lpwh->session_deleted = FALSE; lpwh->session_deleted = FALSE;
@ -2242,7 +2242,7 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
lpwfs->hdr.dwFlags = dwFlags; lpwfs->hdr.dwFlags = dwFlags;
lpwfs->hdr.dwContext = dwContext; lpwfs->hdr.dwContext = dwContext;
lpwfs->hdr.dwInternalFlags = dwInternalFlags; lpwfs->hdr.dwInternalFlags = dwInternalFlags;
lpwfs->hdr.dwRefCount = 1; lpwfs->hdr.refs = 1;
lpwfs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB; lpwfs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB;
lpwfs->download_in_progress = NULL; lpwfs->download_in_progress = NULL;
lpwfs->sndSocket = -1; lpwfs->sndSocket = -1;
@ -3293,7 +3293,7 @@ static HINTERNET FTP_ReceiveFileList(LPWININETFTPSESSIONW lpwfs, INT nSocket, LP
lpwfn->hdr.htype = WH_HFTPFINDNEXT; lpwfn->hdr.htype = WH_HFTPFINDNEXT;
lpwfn->hdr.vtbl = &FTPFINDNEXTVtbl; lpwfn->hdr.vtbl = &FTPFINDNEXTVtbl;
lpwfn->hdr.dwContext = dwContext; lpwfn->hdr.dwContext = dwContext;
lpwfn->hdr.dwRefCount = 1; lpwfn->hdr.refs = 1;
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 */
lpwfn->size = dwSize; lpwfn->size = dwSize;

View File

@ -1606,7 +1606,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
lpwhr->hdr.vtbl = &HTTPREQVtbl; lpwhr->hdr.vtbl = &HTTPREQVtbl;
lpwhr->hdr.dwFlags = dwFlags; lpwhr->hdr.dwFlags = dwFlags;
lpwhr->hdr.dwContext = dwContext; lpwhr->hdr.dwContext = dwContext;
lpwhr->hdr.dwRefCount = 1; lpwhr->hdr.refs = 1;
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;
@ -3159,7 +3159,7 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
lpwhs->hdr.dwFlags = dwFlags; lpwhs->hdr.dwFlags = dwFlags;
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.refs = 1;
lpwhs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB; lpwhs->hdr.lpfnStatusCB = hIC->hdr.lpfnStatusCB;
WININET_AddRef( &hIC->hdr ); WININET_AddRef( &hIC->hdr );

View File

@ -145,8 +145,8 @@ end:
LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info ) LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info )
{ {
info->dwRefCount++; ULONG refs = InterlockedIncrement(&info->refs);
TRACE("%p -> refcount = %d\n", info, info->dwRefCount ); TRACE("%p -> refcount = %d\n", info, refs );
return info; return info;
} }
@ -170,9 +170,9 @@ LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet )
BOOL WININET_Release( LPWININETHANDLEHEADER info ) BOOL WININET_Release( LPWININETHANDLEHEADER info )
{ {
info->dwRefCount--; ULONG refs = InterlockedDecrement(&info->refs);
TRACE( "object %p refcount = %d\n", info, info->dwRefCount ); TRACE( "object %p refcount = %d\n", info, refs );
if( !info->dwRefCount ) if( !refs )
{ {
if ( info->vtbl->CloseConnection ) if ( info->vtbl->CloseConnection )
{ {
@ -537,7 +537,7 @@ HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
lpwai->hdr.htype = WH_HINIT; lpwai->hdr.htype = WH_HINIT;
lpwai->hdr.vtbl = &APPINFOVtbl; lpwai->hdr.vtbl = &APPINFOVtbl;
lpwai->hdr.dwFlags = dwFlags; lpwai->hdr.dwFlags = dwFlags;
lpwai->hdr.dwRefCount = 1; lpwai->hdr.refs = 1;
lpwai->dwAccessType = dwAccessType; lpwai->dwAccessType = dwAccessType;
lpwai->lpszProxyUsername = NULL; lpwai->lpszProxyUsername = NULL;
lpwai->lpszProxyPassword = NULL; lpwai->lpszProxyPassword = NULL;

View File

@ -156,7 +156,7 @@ struct _WININETHANDLEHEADER
DWORD_PTR dwContext; DWORD_PTR dwContext;
DWORD dwError; DWORD dwError;
DWORD dwInternalFlags; DWORD dwInternalFlags;
DWORD dwRefCount; LONG refs;
INTERNET_STATUS_CALLBACK lpfnStatusCB; INTERNET_STATUS_CALLBACK lpfnStatusCB;
struct list entry; struct list entry;
struct list children; struct list children;