summaryrefslogtreecommitdiff
path: root/sql/nt_servc.h
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2020-07-04 18:24:40 +0200
committerVladislav Vaintroub <wlad@mariadb.com>2020-07-04 18:24:40 +0200
commit9701759b3d9ea9fd9bee640ce27171bdd51b7e78 (patch)
tree88ad4445989ffb68b1f3af82642749ca50372ab9 /sql/nt_servc.h
parentd46576b35ac0775e6500ee15e828f29c74998262 (diff)
downloadmariadb-git-9701759b3d9ea9fd9bee640ce27171bdd51b7e78.tar.gz
MDEV-23043 Refactor Windows service handling
Removed the existing nt_service classes - they provide little abstraction, and only obscure a relatively simple service handling. This replaces by similar code inspired by MS docs samples. Service handling is now moved into winmain.cc, which contains the main() function for Windows. winmain provides reporting callbacks, which should be used by external code ,to report transitions from starting to running to shutting down to stopped. Removed a do-nothing ServiceMain thread, and the non-working service "pause/continue". Removed a lot of #ifdef __WIN__ code from mysqld.cc
Diffstat (limited to 'sql/nt_servc.h')
-rw-r--r--sql/nt_servc.h113
1 files changed, 0 insertions, 113 deletions
diff --git a/sql/nt_servc.h b/sql/nt_servc.h
deleted file mode 100644
index 8ba29519c8f..00000000000
--- a/sql/nt_servc.h
+++ /dev/null
@@ -1,113 +0,0 @@
-#ifndef NT_SERVC_INCLUDED
-#define NT_SERVC_INCLUDED
-
-/**
- @file
-
- @brief
- Windows NT Service class library
-
- Copyright Abandoned 1998 Irena Pancirov - Irnet Snc
- This file is public domain and comes with NO WARRANTY of any kind
-*/
-
-// main application thread
-typedef void (*THREAD_FC)(void *);
-
-class NTService
-{
- public:
- NTService();
- ~NTService();
-
- BOOL bOsNT; ///< true if OS is NT, false for Win95
- //install optinos
- DWORD dwDesiredAccess;
- DWORD dwServiceType;
- DWORD dwStartType;
- DWORD dwErrorControl;
-
- LPSTR szLoadOrderGroup;
- LPDWORD lpdwTagID;
- LPSTR szDependencies;
- OSVERSIONINFO osVer;
-
- // time-out (in milisec)
- int nStartTimeOut;
- int nStopTimeOut;
- int nPauseTimeOut;
- int nResumeTimeOut;
-
- //
- DWORD my_argc;
- LPTSTR *my_argv;
- HANDLE hShutdownEvent;
- int nError;
- DWORD dwState;
-
- //init service entry point
- long Init(LPCSTR szInternName,THREAD_FC ServiceThread);
-
- //application shutdown event
- void SetShutdownEvent(HANDLE hEvent){ hShutdownEvent=hEvent; }
-
-
- //service install / un-install
- BOOL Install(int startType,LPCSTR szInternName,LPCSTR szDisplayName,
- LPCSTR szFullPath, LPCSTR szAccountName=NULL,
- LPCSTR szPassword=NULL);
- BOOL SeekStatus(LPCSTR szInternName, int OperationType);
- BOOL Remove(LPCSTR szInternName);
- BOOL IsService(LPCSTR ServiceName);
- BOOL got_service_option(char **argv, const char *service_option);
- BOOL is_super_user();
-
- /*
- SetRunning() is to be called by the application
- when initialization completes and it can accept
- stop request
- */
- void SetRunning(void);
-
- /**
- Sets a timeout after which SCM will abort service startup if SetRunning()
- was not called or the timeout was not extended with another call to
- SetSlowStarting(). Should be called when static initialization completes,
- and the variable initialization part begins
-
- @arg timeout the timeout to pass to the SCM (in milliseconds)
- */
- void SetSlowStarting(unsigned long timeout);
-
- /*
- Stop() is to be called by the application to stop
- the service
- */
- void Stop(void);
-
- protected:
- LPSTR ServiceName;
- HANDLE hExitEvent;
- SERVICE_STATUS_HANDLE hServiceStatusHandle;
- BOOL bPause;
- BOOL bRunning;
- HANDLE hThreadHandle;
- THREAD_FC fpServiceThread;
-
- void PauseService();
- void ResumeService();
- void StopService();
- BOOL StartService();
-
- static void WINAPI ServiceMain(DWORD argc, LPTSTR *argv);
- static void WINAPI ServiceCtrlHandler (DWORD ctrlCode);
-
- void Exit(DWORD error);
- BOOL SetStatus (DWORD dwCurrentState,DWORD dwWin32ExitCode,
- DWORD dwServiceSpecificExitCode,
- DWORD dwCheckPoint,DWORD dwWaitHint);
-
-};
-/* ------------------------- the end -------------------------------------- */
-
-#endif /* NT_SERVC_INCLUDED */