diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c0a1b2e530681a5e4e74e03a0c9e87d778d2b266..16e2364199dcd0dea5e8858f84c50d61ceedbc91 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4368,6 +4368,9 @@ we force server id to 2, but this MySQL server will not act as a slave."); : mysqld_unix_port), mysqld_port, MYSQL_COMPILATION_COMMENT); +#if defined(_WIN32) && !defined(EMBEDDED_LIBRARY) + Service.SetRunning(); +#endif /* Signal threads waiting for server to be started */ diff --git a/sql/nt_servc.cc b/sql/nt_servc.cc index 7ff06d5bdf52e01f0455b01a0cbb47c532fc61af..f41fa08f8284877d928e81c0478be721f5257848 100644 --- a/sql/nt_servc.cc +++ b/sql/nt_servc.cc @@ -255,10 +255,6 @@ void NTService::ServiceMain(DWORD argc, LPTSTR *argv) if (!pService->StartService()) goto error; - // Check that the service is now running. - if (!pService->SetStatus(SERVICE_RUNNING,NO_ERROR, 0, 0, 0)) - goto error; - // wait for exit event WaitForSingleObject (pService->hExitEvent, INFINITE); @@ -274,9 +270,18 @@ error: return; } -/** - starts the appliaction thread. -*/ + + +void NTService::SetRunning() +{ + if (pService) + pService->SetStatus(SERVICE_RUNNING,NO_ERROR, 0, 0, 0); +} + + +/* ------------------------------------------------------------------------ + StartService() - starts the application thread + -------------------------------------------------------------------------- */ BOOL NTService::StartService() { diff --git a/sql/nt_servc.h b/sql/nt_servc.h index 525f709388b53e3970c827b78d870a13270dc7df..2f0d07df543295f3eddb38eb680faa11ef369265 100644 --- a/sql/nt_servc.h +++ b/sql/nt_servc.h @@ -60,7 +60,19 @@ class NTService BOOL IsService(LPCSTR ServiceName); BOOL got_service_option(char **argv, char *service_option); BOOL is_super_user(); - void Stop(void); //to be called from app. to stop service + + /* + SetRunning() is to be called by the application + when initialization completes and it can accept + stop request + */ + void SetRunning(void); + + /* + Stop() is to be called by the application to stop + the service + */ + void Stop(void); protected: LPSTR ServiceName;