mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
alot of formatting changes that came out of JimW's review
This commit is contained in:
@ -25,7 +25,6 @@ void IMService::Run()
|
|||||||
ReportStatus((DWORD)SERVICE_START_PENDING);
|
ReportStatus((DWORD)SERVICE_START_PENDING);
|
||||||
|
|
||||||
// init goes here
|
// init goes here
|
||||||
|
|
||||||
ReportStatus((DWORD)SERVICE_RUNNING);
|
ReportStatus((DWORD)SERVICE_RUNNING);
|
||||||
|
|
||||||
// wait for main loop to terminate
|
// wait for main loop to terminate
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
|
|
||||||
static WindowsService *gService;
|
static WindowsService *gService;
|
||||||
|
|
||||||
WindowsService::WindowsService(void)
|
WindowsService::WindowsService(void) :
|
||||||
: statusCheckpoint(0), serviceName(NULL), inited(false),
|
statusCheckpoint(0),
|
||||||
|
serviceName(NULL),
|
||||||
|
inited(false),
|
||||||
dwAcceptedControls(SERVICE_ACCEPT_STOP)
|
dwAcceptedControls(SERVICE_ACCEPT_STOP)
|
||||||
{
|
{
|
||||||
gService= this;
|
gService= this;
|
||||||
@ -34,9 +36,10 @@ BOOL WindowsService::Install()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
newService= CreateService(scm, serviceName, displayName,
|
newService= CreateService(scm, serviceName, displayName,
|
||||||
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START,
|
SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
|
||||||
SERVICE_ERROR_NORMAL, szFilePath,
|
SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
|
||||||
NULL, NULL, NULL, username, password);
|
szFilePath, NULL, NULL, NULL, username,
|
||||||
|
password);
|
||||||
|
|
||||||
if (newService)
|
if (newService)
|
||||||
{
|
{
|
||||||
@ -109,7 +112,8 @@ void WindowsService::SetAcceptedControls(DWORD acceptedControls)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL WindowsService::ReportStatus(DWORD currentState, DWORD waitHint, DWORD dwError)
|
BOOL WindowsService::ReportStatus(DWORD currentState, DWORD waitHint,
|
||||||
|
DWORD dwError)
|
||||||
{
|
{
|
||||||
if(debugging) return TRUE;
|
if(debugging) return TRUE;
|
||||||
|
|
||||||
@ -119,7 +123,8 @@ BOOL WindowsService::ReportStatus(DWORD currentState, DWORD waitHint, DWORD dwEr
|
|||||||
status.dwControlsAccepted= dwAcceptedControls;
|
status.dwControlsAccepted= dwAcceptedControls;
|
||||||
|
|
||||||
status.dwCurrentState= currentState;
|
status.dwCurrentState= currentState;
|
||||||
status.dwWin32ExitCode = dwError != 0 ? ERROR_SERVICE_SPECIFIC_ERROR : NO_ERROR;
|
status.dwWin32ExitCode= dwError != 0 ?
|
||||||
|
ERROR_SERVICE_SPECIFIC_ERROR : NO_ERROR;
|
||||||
status.dwWaitHint= waitHint;
|
status.dwWaitHint= waitHint;
|
||||||
status.dwServiceSpecificExitCode= dwError;
|
status.dwServiceSpecificExitCode= dwError;
|
||||||
|
|
||||||
|
@ -377,7 +377,8 @@ BOOL SafeTerminateProcess(HANDLE hProcess, UINT uExitCode)
|
|||||||
BOOL bSuccess= FALSE;
|
BOOL bSuccess= FALSE;
|
||||||
|
|
||||||
BOOL bDup= DuplicateHandle(GetCurrentProcess(),
|
BOOL bDup= DuplicateHandle(GetCurrentProcess(),
|
||||||
hProcess, GetCurrentProcess(), &hProcessDup, PROCESS_ALL_ACCESS, FALSE, 0);
|
hProcess, GetCurrentProcess(), &hProcessDup,
|
||||||
|
PROCESS_ALL_ACCESS, FALSE, 0);
|
||||||
|
|
||||||
// Detect the special case where the process is
|
// Detect the special case where the process is
|
||||||
// already dead...
|
// already dead...
|
||||||
@ -389,15 +390,14 @@ BOOL SafeTerminateProcess(HANDLE hProcess, UINT uExitCode)
|
|||||||
pfnExitProc= GetProcAddress(hKernel, "ExitProcess");
|
pfnExitProc= GetProcAddress(hKernel, "ExitProcess");
|
||||||
|
|
||||||
hRT= CreateRemoteThread((bDup) ? hProcessDup : hProcess, NULL, 0,
|
hRT= CreateRemoteThread((bDup) ? hProcessDup : hProcess, NULL, 0,
|
||||||
(LPTHREAD_START_ROUTINE)pfnExitProc, (PVOID)uExitCode, 0, &dwTID);
|
(LPTHREAD_START_ROUTINE)pfnExitProc,
|
||||||
|
(PVOID)uExitCode, 0, &dwTID);
|
||||||
|
|
||||||
if (hRT == NULL)
|
if (hRT == NULL)
|
||||||
dwErr= GetLastError();
|
dwErr= GetLastError();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
dwErr= ERROR_PROCESS_ABORTED;
|
dwErr= ERROR_PROCESS_ABORTED;
|
||||||
}
|
|
||||||
|
|
||||||
if (hRT)
|
if (hRT)
|
||||||
{
|
{
|
||||||
|
@ -256,8 +256,8 @@ int Instance_map::load()
|
|||||||
else
|
else
|
||||||
argv_options[1]= '\0';
|
argv_options[1]= '\0';
|
||||||
|
|
||||||
if (my_search_option_files(Options::config_file, &argc, (char ***) &argv, &args_used,
|
if (my_search_option_files(Options::config_file, &argc, (char ***) &argv,
|
||||||
process_option, (void*) this) ||
|
&args_used, process_option, (void*) this) ||
|
||||||
complete_initialization())
|
complete_initialization())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ Listener_thread::Listener_thread(const Listener_thread_args &args) :
|
|||||||
args.instance_map)
|
args.instance_map)
|
||||||
,total_connection_count(0)
|
,total_connection_count(0)
|
||||||
,thread_info(pthread_self())
|
,thread_info(pthread_self())
|
||||||
|
,num_sockets(0)
|
||||||
{
|
{
|
||||||
num_sockets= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ void Listener_thread::run()
|
|||||||
n= max(n, sockets[i]);
|
n= max(n, sockets[i]);
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
while (thread_registry.is_shutdown() == false)
|
while (!thread_registry.is_shutdown())
|
||||||
{
|
{
|
||||||
fd_set read_fds_arg= read_fds;
|
fd_set read_fds_arg= read_fds;
|
||||||
|
|
||||||
@ -149,8 +149,8 @@ void Listener_thread::run()
|
|||||||
/* accept may return -1 (failure or spurious wakeup) */
|
/* accept may return -1 (failure or spurious wakeup) */
|
||||||
if (client_fd >= 0) // connection established
|
if (client_fd >= 0) // connection established
|
||||||
{
|
{
|
||||||
Vio *vio = vio_new(client_fd, socket_index==0?VIO_TYPE_SOCKET:VIO_TYPE_TCPIP,
|
Vio *vio = vio_new(client_fd, socket_index==0?VIO_TYPE_SOCKET:
|
||||||
socket_index==0?1:0);
|
VIO_TYPE_TCPIP, socket_index==0?1:0);
|
||||||
if (vio != 0)
|
if (vio != 0)
|
||||||
handle_new_mysql_connection(vio);
|
handle_new_mysql_connection(vio);
|
||||||
else
|
else
|
||||||
@ -179,6 +179,10 @@ void Listener_thread::run()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
// we have to close the ip sockets in case of error
|
||||||
|
for (int i= 0; i < num_sockets; i++)
|
||||||
|
close(sockets[i]);
|
||||||
|
|
||||||
thread_registry.unregister_thread(&thread_info);
|
thread_registry.unregister_thread(&thread_info);
|
||||||
thread_registry.request_shutdown();
|
thread_registry.request_shutdown();
|
||||||
my_thread_end();
|
my_thread_end();
|
||||||
|
@ -252,14 +252,15 @@ int Options::load(int argc, char **argv)
|
|||||||
Options::first_option= argv[1];
|
Options::first_option= argv[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// we were not given a config file on the command line so we
|
/*
|
||||||
// set have to construct a new argv array
|
we were not given a config file on the command line so we
|
||||||
|
default to our compiled in default
|
||||||
|
*/
|
||||||
if (config_file == NULL)
|
if (config_file == NULL)
|
||||||
{
|
{
|
||||||
#ifdef __WIN__
|
#ifdef __WIN__
|
||||||
::GetModuleFileName(NULL, default_config_file, sizeof(default_config_file));
|
::GetModuleFileName(NULL, default_config_file, sizeof(default_config_file)); char *filename= strrchr(default_config_file, "\\");
|
||||||
char *filename = strstr(default_config_file, "mysqlmanager.exe");
|
strcpy(filename, "\\my.ini");
|
||||||
strcpy(filename, "my.ini");
|
|
||||||
#endif
|
#endif
|
||||||
config_file= default_config_file;
|
config_file= default_config_file;
|
||||||
}
|
}
|
||||||
@ -281,7 +282,6 @@ void Options::cleanup()
|
|||||||
{
|
{
|
||||||
/* free_defaults returns nothing */
|
/* free_defaults returns nothing */
|
||||||
free_defaults(Options::saved_argv);
|
free_defaults(Options::saved_argv);
|
||||||
|
|
||||||
#ifdef __WIN__
|
#ifdef __WIN__
|
||||||
free((char*)default_password_file_name);
|
free((char*)default_password_file_name);
|
||||||
#endif
|
#endif
|
||||||
@ -304,8 +304,10 @@ char* change_extension(const char *src, const char *newext)
|
|||||||
|
|
||||||
void Options::setup_windows_defaults(const char *progname)
|
void Options::setup_windows_defaults(const char *progname)
|
||||||
{
|
{
|
||||||
Options::password_file_name = default_password_file_name = change_extension(progname, "passwd");
|
Options::password_file_name= default_password_file_name =
|
||||||
Options::log_file_name = default_log_file_name = change_extension(progname, "log");
|
change_extension(progname, "passwd");
|
||||||
|
Options::log_file_name= default_log_file_name =
|
||||||
|
change_extension(progname, "log");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user