From 5f72ec063f99ccb105c49206ccc36db843b5443c Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Thu, 30 Mar 2017 22:47:59 +0200 Subject: [PATCH] msvcrt: Attach context to default scheduler on creation. Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcrt/cxx.h | 1 + dlls/msvcrt/scheduler.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/msvcrt/cxx.h b/dlls/msvcrt/cxx.h index aefebdc0198..476f66a7c79 100644 --- a/dlls/msvcrt/cxx.h +++ b/dlls/msvcrt/cxx.h @@ -267,6 +267,7 @@ typedef struct extern void *vtbl_wrapper_0; extern void *vtbl_wrapper_4; extern void *vtbl_wrapper_8; +extern void *vtbl_wrapper_16; extern void *vtbl_wrapper_20; extern void *vtbl_wrapper_28; diff --git a/dlls/msvcrt/scheduler.c b/dlls/msvcrt/scheduler.c index 93dae7fff59..8487752a03b 100644 --- a/dlls/msvcrt/scheduler.c +++ b/dlls/msvcrt/scheduler.c @@ -49,6 +49,7 @@ static int scheduler_id = -1; DEFINE_VTBL_WRAPPER(0); DEFINE_VTBL_WRAPPER(4); DEFINE_VTBL_WRAPPER(8); +DEFINE_VTBL_WRAPPER(16); DEFINE_VTBL_WRAPPER(20); DEFINE_VTBL_WRAPPER(28); @@ -114,6 +115,7 @@ static void ExternalContextBase_ctor(ExternalContextBase*); typedef struct Scheduler { const vtable_ptr *vtable; } Scheduler; +#define call_Scheduler_Reference(this) CALL_VTBL_FUNC(this, 16, unsigned int, (Scheduler*), (this)) #define call_Scheduler_Release(this) CALL_VTBL_FUNC(this, 20, unsigned int, (Scheduler*), (this)) #define call_Scheduler_Attach(this) CALL_VTBL_FUNC(this, 28, void, (Scheduler*), (this)) @@ -143,6 +145,8 @@ static CRITICAL_SECTION default_scheduler_cs = { &default_scheduler_cs_debug, -1 static SchedulerPolicy default_scheduler_policy; static ThreadScheduler *default_scheduler; +static void create_default_scheduler(void); + static Context* try_get_current_context(void) { if (context_tls_index == TLS_OUT_OF_INDEXES) @@ -325,6 +329,10 @@ static void ExternalContextBase_ctor(ExternalContextBase *this) memset(this, 0, sizeof(*this)); this->context.vtable = &MSVCRT_ExternalContextBase_vtable; this->id = InterlockedIncrement(&context_id); + + create_default_scheduler(); + this->scheduler.scheduler = &default_scheduler->scheduler; + call_Scheduler_Reference(&default_scheduler->scheduler); } /* ?Alloc@Concurrency@@YAPAXI@Z */ @@ -834,7 +842,7 @@ Scheduler* __cdecl CurrentScheduler_Get(void) create_default_scheduler(); context->scheduler.scheduler = &default_scheduler->scheduler; - ThreadScheduler_Reference(default_scheduler); + call_Scheduler_Reference(&default_scheduler->scheduler); return &default_scheduler->scheduler; }