crypt32: Moved critical section out of ContextList struct.
This commit is contained in:
parent
6cf1e0d75c
commit
724754da64
|
@ -112,7 +112,6 @@ void Context_CopyProperties(const void *to, const void *from)
|
||||||
|
|
||||||
struct ContextList
|
struct ContextList
|
||||||
{
|
{
|
||||||
CRITICAL_SECTION cs;
|
|
||||||
struct list contexts;
|
struct list contexts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,14 +121,13 @@ struct ContextList *ContextList_Create(void)
|
||||||
|
|
||||||
if (list)
|
if (list)
|
||||||
{
|
{
|
||||||
InitializeCriticalSection(&list->cs);
|
|
||||||
list->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ContextList.cs");
|
|
||||||
list_init(&list->contexts);
|
list_init(&list->contexts);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
context_t *ContextList_Add(struct ContextList *list, context_t *toLink, context_t *existing, struct WINE_CRYPTCERTSTORE *store, BOOL use_link)
|
context_t *ContextList_Add(struct ContextList *list, CRITICAL_SECTION *cs, context_t *toLink,
|
||||||
|
context_t *existing, struct WINE_CRYPTCERTSTORE *store, BOOL use_link)
|
||||||
{
|
{
|
||||||
context_t *context;
|
context_t *context;
|
||||||
|
|
||||||
|
@ -139,7 +137,7 @@ context_t *ContextList_Add(struct ContextList *list, context_t *toLink, context_
|
||||||
if (context)
|
if (context)
|
||||||
{
|
{
|
||||||
TRACE("adding %p\n", context);
|
TRACE("adding %p\n", context);
|
||||||
EnterCriticalSection(&list->cs);
|
EnterCriticalSection(cs);
|
||||||
if (existing)
|
if (existing)
|
||||||
{
|
{
|
||||||
context->u.entry.prev = existing->u.entry.prev;
|
context->u.entry.prev = existing->u.entry.prev;
|
||||||
|
@ -151,17 +149,17 @@ context_t *ContextList_Add(struct ContextList *list, context_t *toLink, context_
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
list_add_head(&list->contexts, &context->u.entry);
|
list_add_head(&list->contexts, &context->u.entry);
|
||||||
LeaveCriticalSection(&list->cs);
|
LeaveCriticalSection(cs);
|
||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
context_t *ContextList_Enum(struct ContextList *list, context_t *prev)
|
context_t *ContextList_Enum(struct ContextList *list, CRITICAL_SECTION *cs, context_t *prev)
|
||||||
{
|
{
|
||||||
struct list *listNext;
|
struct list *listNext;
|
||||||
context_t *ret;
|
context_t *ret;
|
||||||
|
|
||||||
EnterCriticalSection(&list->cs);
|
EnterCriticalSection(cs);
|
||||||
if (prev)
|
if (prev)
|
||||||
{
|
{
|
||||||
listNext = list_next(&list->contexts, &prev->u.entry);
|
listNext = list_next(&list->contexts, &prev->u.entry);
|
||||||
|
@ -169,7 +167,7 @@ context_t *ContextList_Enum(struct ContextList *list, context_t *prev)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
listNext = list_next(&list->contexts, &list->contexts);
|
listNext = list_next(&list->contexts, &list->contexts);
|
||||||
LeaveCriticalSection(&list->cs);
|
LeaveCriticalSection(cs);
|
||||||
|
|
||||||
if (listNext)
|
if (listNext)
|
||||||
{
|
{
|
||||||
|
@ -181,18 +179,18 @@ context_t *ContextList_Enum(struct ContextList *list, context_t *prev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL ContextList_Remove(struct ContextList *list, context_t *context)
|
BOOL ContextList_Remove(struct ContextList *list, CRITICAL_SECTION *cs, context_t *context)
|
||||||
{
|
{
|
||||||
BOOL inList = FALSE;
|
BOOL inList = FALSE;
|
||||||
|
|
||||||
EnterCriticalSection(&list->cs);
|
EnterCriticalSection(cs);
|
||||||
if (!list_empty(&context->u.entry))
|
if (!list_empty(&context->u.entry))
|
||||||
{
|
{
|
||||||
list_remove(&context->u.entry);
|
list_remove(&context->u.entry);
|
||||||
list_init(&context->u.entry);
|
list_init(&context->u.entry);
|
||||||
inList = TRUE;
|
inList = TRUE;
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&list->cs);
|
LeaveCriticalSection(cs);
|
||||||
|
|
||||||
return inList;
|
return inList;
|
||||||
}
|
}
|
||||||
|
@ -201,20 +199,16 @@ static void ContextList_Empty(struct ContextList *list)
|
||||||
{
|
{
|
||||||
context_t *context, *next;
|
context_t *context, *next;
|
||||||
|
|
||||||
EnterCriticalSection(&list->cs);
|
|
||||||
LIST_FOR_EACH_ENTRY_SAFE(context, next, &list->contexts, context_t, u.entry)
|
LIST_FOR_EACH_ENTRY_SAFE(context, next, &list->contexts, context_t, u.entry)
|
||||||
{
|
{
|
||||||
TRACE("removing %p\n", context);
|
TRACE("removing %p\n", context);
|
||||||
list_remove(&context->u.entry);
|
list_remove(&context->u.entry);
|
||||||
Context_Release(context);
|
Context_Release(context);
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&list->cs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextList_Free(struct ContextList *list)
|
void ContextList_Free(struct ContextList *list)
|
||||||
{
|
{
|
||||||
ContextList_Empty(list);
|
ContextList_Empty(list);
|
||||||
list->cs.DebugInfo->Spare[0] = 0;
|
|
||||||
DeleteCriticalSection(&list->cs);
|
|
||||||
CryptMemFree(list);
|
CryptMemFree(list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -440,16 +440,16 @@ struct ContextList;
|
||||||
|
|
||||||
struct ContextList *ContextList_Create(void) DECLSPEC_HIDDEN;
|
struct ContextList *ContextList_Create(void) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
context_t *ContextList_Add(struct ContextList *list, context_t *toLink, context_t *toReplace,
|
context_t *ContextList_Add(struct ContextList *list, CRITICAL_SECTION *cs, context_t *toLink, context_t *toReplace,
|
||||||
struct WINE_CRYPTCERTSTORE *store, BOOL use_link) DECLSPEC_HIDDEN;
|
struct WINE_CRYPTCERTSTORE *store, BOOL use_link) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
context_t *ContextList_Enum(struct ContextList *list, context_t *prev) DECLSPEC_HIDDEN;
|
context_t *ContextList_Enum(struct ContextList *list, CRITICAL_SECTION *cs, context_t *prev) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/* Removes a context from the list. Returns TRUE if the context was removed,
|
/* Removes a context from the list. Returns TRUE if the context was removed,
|
||||||
* or FALSE if not. (The context may have been duplicated, so subsequent
|
* or FALSE if not. (The context may have been duplicated, so subsequent
|
||||||
* removes have no effect.)
|
* removes have no effect.)
|
||||||
*/
|
*/
|
||||||
BOOL ContextList_Remove(struct ContextList *list, context_t *context) DECLSPEC_HIDDEN;
|
BOOL ContextList_Remove(struct ContextList *list, CRITICAL_SECTION *cs, context_t *context) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
void ContextList_Free(struct ContextList *list) DECLSPEC_HIDDEN;
|
void ContextList_Free(struct ContextList *list) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ const WINE_CONTEXT_INTERFACE *pCTLInterface = &gCTLInterface;
|
||||||
typedef struct _WINE_MEMSTORE
|
typedef struct _WINE_MEMSTORE
|
||||||
{
|
{
|
||||||
WINECRYPT_CERTSTORE hdr;
|
WINECRYPT_CERTSTORE hdr;
|
||||||
|
CRITICAL_SECTION cs;
|
||||||
struct ContextList *certs;
|
struct ContextList *certs;
|
||||||
struct ContextList *crls;
|
struct ContextList *crls;
|
||||||
struct ContextList *ctls;
|
struct ContextList *ctls;
|
||||||
|
@ -150,7 +151,7 @@ static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
|
||||||
|
|
||||||
TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
|
TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
|
||||||
|
|
||||||
context = ContextList_Add(ms->certs, cert, toReplace, store, use_link);
|
context = ContextList_Add(ms->certs, &ms->cs, cert, toReplace, store, use_link);
|
||||||
if (!context)
|
if (!context)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -168,7 +169,7 @@ static context_t *MemStore_enumCert(WINECRYPT_CERTSTORE *store, context_t *prev)
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", store, prev);
|
TRACE("(%p, %p)\n", store, prev);
|
||||||
|
|
||||||
ret = ContextList_Enum(ms->certs, prev);
|
ret = ContextList_Enum(ms->certs, &ms->cs, prev);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
SetLastError(CRYPT_E_NOT_FOUND);
|
SetLastError(CRYPT_E_NOT_FOUND);
|
||||||
|
|
||||||
|
@ -180,7 +181,7 @@ static BOOL MemStore_deleteCert(WINECRYPT_CERTSTORE *store, context_t *context)
|
||||||
{
|
{
|
||||||
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
|
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
|
||||||
|
|
||||||
if (ContextList_Remove(ms->certs, context))
|
if (ContextList_Remove(ms->certs, &ms->cs, context))
|
||||||
Context_Release(context);
|
Context_Release(context);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -194,7 +195,7 @@ static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl,
|
||||||
|
|
||||||
TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext);
|
TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext);
|
||||||
|
|
||||||
context = ContextList_Add(ms->crls, crl, toReplace, store, use_link);
|
context = ContextList_Add(ms->crls, &ms->cs, crl, toReplace, store, use_link);
|
||||||
if (!context)
|
if (!context)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -212,7 +213,7 @@ static context_t *MemStore_enumCRL(WINECRYPT_CERTSTORE *store, context_t *prev)
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", store, prev);
|
TRACE("(%p, %p)\n", store, prev);
|
||||||
|
|
||||||
ret = ContextList_Enum(ms->crls, prev);
|
ret = ContextList_Enum(ms->crls, &ms->cs, prev);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
SetLastError(CRYPT_E_NOT_FOUND);
|
SetLastError(CRYPT_E_NOT_FOUND);
|
||||||
|
|
||||||
|
@ -224,7 +225,7 @@ static BOOL MemStore_deleteCRL(WINECRYPT_CERTSTORE *store, context_t *context)
|
||||||
{
|
{
|
||||||
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
|
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
|
||||||
|
|
||||||
if (!ContextList_Remove(ms->crls, context))
|
if (!ContextList_Remove(ms->crls, &ms->cs, context))
|
||||||
Context_Release(context);
|
Context_Release(context);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -238,7 +239,7 @@ static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl,
|
||||||
|
|
||||||
TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext);
|
TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext);
|
||||||
|
|
||||||
context = ContextList_Add(ms->ctls, ctl, toReplace, store, use_link);
|
context = ContextList_Add(ms->ctls, &ms->cs, ctl, toReplace, store, use_link);
|
||||||
if (!context)
|
if (!context)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -256,7 +257,7 @@ static context_t *MemStore_enumCTL(WINECRYPT_CERTSTORE *store, context_t *prev)
|
||||||
|
|
||||||
TRACE("(%p, %p)\n", store, prev);
|
TRACE("(%p, %p)\n", store, prev);
|
||||||
|
|
||||||
ret = ContextList_Enum(ms->ctls, prev);
|
ret = ContextList_Enum(ms->ctls, &ms->cs, prev);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
SetLastError(CRYPT_E_NOT_FOUND);
|
SetLastError(CRYPT_E_NOT_FOUND);
|
||||||
|
|
||||||
|
@ -268,7 +269,7 @@ static BOOL MemStore_deleteCTL(WINECRYPT_CERTSTORE *store, context_t *context)
|
||||||
{
|
{
|
||||||
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
|
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
|
||||||
|
|
||||||
if (!ContextList_Remove(ms->ctls, context))
|
if (!ContextList_Remove(ms->ctls, &ms->cs, context))
|
||||||
Context_Release(context);
|
Context_Release(context);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -296,6 +297,8 @@ static DWORD MemStore_release(WINECRYPT_CERTSTORE *cert_store, DWORD flags)
|
||||||
ContextList_Free(store->certs);
|
ContextList_Free(store->certs);
|
||||||
ContextList_Free(store->crls);
|
ContextList_Free(store->crls);
|
||||||
ContextList_Free(store->ctls);
|
ContextList_Free(store->ctls);
|
||||||
|
store->cs.DebugInfo->Spare[0] = 0;
|
||||||
|
DeleteCriticalSection(&store->cs);
|
||||||
CRYPT_FreeStore(&store->hdr);
|
CRYPT_FreeStore(&store->hdr);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -345,6 +348,8 @@ static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
|
||||||
{
|
{
|
||||||
memset(store, 0, sizeof(WINE_MEMSTORE));
|
memset(store, 0, sizeof(WINE_MEMSTORE));
|
||||||
CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeMem, &MemStoreVtbl);
|
CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeMem, &MemStoreVtbl);
|
||||||
|
InitializeCriticalSection(&store->cs);
|
||||||
|
store->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ContextList.cs");
|
||||||
store->certs = ContextList_Create();
|
store->certs = ContextList_Create();
|
||||||
store->crls = ContextList_Create();
|
store->crls = ContextList_Create();
|
||||||
store->ctls = ContextList_Create();
|
store->ctls = ContextList_Create();
|
||||||
|
|
Loading…
Reference in New Issue