From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/msvcrt/concurrency.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/dlls/msvcrt/concurrency.c b/dlls/msvcrt/concurrency.c index 76a1f22fbbe..9b301299f35 100644 --- a/dlls/msvcrt/concurrency.c +++ b/dlls/msvcrt/concurrency.c @@ -91,6 +91,7 @@ struct scheduler_list {
typedef struct { Context context; + LONG refcount; struct scheduler_list scheduler; unsigned int id; union allocator_cache_entry *allocator_cache[8]; @@ -846,6 +847,11 @@ static void ExternalContextBase_dtor(ExternalContextBase *this) union allocator_cache_entry *next, *cur; int i;
+ if (InterlockedDecrement(&this->refcount)) { + TRACE("skipping dtor: refcount not zero\n"); + return; + } + /* TODO: move the allocator cache to scheduler so it can be reused */ for(i=0; i<ARRAY_SIZE(this->allocator_cache); i++) { for(cur = this->allocator_cache[i]; cur; cur=next) { @@ -891,6 +897,7 @@ static void ExternalContextBase_ctor(ExternalContextBase *this)
memset(this, 0, sizeof(*this)); this->context.vtable = &ExternalContextBase_vtable; + this->refcount = 1; this->id = InterlockedIncrement(&context_id);
create_default_scheduler();