1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

initial import of Windows port of IM.

server-tools/instance-manager/commands.cc:
  type cleanups for compiling on Windows
  now using Options::config_file for the location of the single 
  my.cnf file we are using
server-tools/instance-manager/guardian.cc:
  pthread_mutex_lock and unlock do not return a value on Windows
  so we return 0 in all cases
server-tools/instance-manager/instance.cc:
  big changes here.
  Had to implement Windows versions of launch_and_wait and kill()
server-tools/instance-manager/instance.h:
  added some function defs
server-tools/instance-manager/instance_map.cc:
  pthread_mutex_lock and unlock do not return a value on Windows
  Also, now using only the file named as Options::config_file
server-tools/instance-manager/instance_options.h:
  added reference to port.h
server-tools/instance-manager/listener.cc:
  reworked and simplified the socket handling code.
  Added windows versions of the code that sets the sockets to be
  non-blocking and non-inheritable
server-tools/instance-manager/listener.h:
  change Options to always be a struct.  Really surprised GCC was 
  letting this go.  Options was declared to be struct in some places
  and class in other places.
server-tools/instance-manager/log.cc:
  added reference to port.h
server-tools/instance-manager/manager.cc:
  moved all the signal code inside some #ifndef __WIN__ blocks
server-tools/instance-manager/manager.h:
  change Options to always be a struct.  Really surprised GCC was 
  letting this go.  Options was declared to be struct in some places
  and class in other places.
server-tools/instance-manager/mysqlmanager.cc:
  added in the Windows service code.
server-tools/instance-manager/options.cc:
  Added in the windows options for running as a service and the code
  for loading settings only from a single file
server-tools/instance-manager/options.h:
  added definitions for the new Windows service vars and routines
server-tools/instance-manager/parse_output.cc:
  added reference to port.h
server-tools/instance-manager/priv.cc:
  added reference to port.h
server-tools/instance-manager/priv.h:
  linuxthreads should not be visible on Windows
server-tools/instance-manager/thread_registry.cc:
  more __WIN__ blocking
server-tools/instance-manager/user_map.cc:
  fixed passwd file code to handle files with \r\n line endings
server-tools/instance-manager/IMService.cpp:
  New BitKeeper file ``server-tools/instance-manager/IMService.cpp''
server-tools/instance-manager/IMService.h:
  New BitKeeper file ``server-tools/instance-manager/IMService.h''
server-tools/instance-manager/WindowsService.cpp:
  New BitKeeper file ``server-tools/instance-manager/WindowsService.cpp''
server-tools/instance-manager/WindowsService.h:
  New BitKeeper file ``server-tools/instance-manager/WindowsService.h''
server-tools/instance-manager/mysqlmanager.vcproj:
  New BitKeeper file ``server-tools/instance-manager/mysqlmanager.vcproj''
server-tools/instance-manager/port.h:
  New BitKeeper file ``server-tools/instance-manager/port.h''
This commit is contained in:
unknown
2005-07-20 10:55:40 -05:00
parent 6ae0603055
commit 875b0e6322
25 changed files with 1236 additions and 220 deletions

View File

@ -23,12 +23,16 @@
#include <my_sys.h>
#include <string.h>
#include <signal.h>
#ifndef __WIN__
#include <pwd.h>
#include <grp.h>
#include <sys/wait.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#ifdef __WIN__
#include "windowsservice.h"
#endif
/*
Few notes about Instance Manager architecture:
@ -55,10 +59,14 @@
*/
static void init_environment(char *progname);
#ifndef __WIN__
static void daemonize(const char *log_file_name);
static void angel(const Options &options);
static struct passwd *check_user(const char *user);
static int set_user(const char *user, struct passwd *user_info);
#else
int HandleServiceOptions(Options options);
#endif
/*
@ -78,6 +86,7 @@ int main(int argc, char *argv[])
if (options.load(argc, argv))
goto err;
#ifndef __WIN__
if ((user_info= check_user(options.user)))
{
if (set_user(options.user, user_info))
@ -94,6 +103,12 @@ int main(int argc, char *argv[])
/* forks again, and returns only in child: parent becomes angel */
angel(options);
}
#else
#ifdef NDEBUG
return HandleServiceOptions(options);
#endif
#endif
manager(options);
options.cleanup();
my_end(0);
@ -105,11 +120,11 @@ err:
/******************* Auxilary functions implementation **********************/
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
/* Change to run as another user if started with --user */
static struct passwd *check_user(const char *user)
{
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
struct passwd *user_info;
uid_t user_id= geteuid();
@ -150,7 +165,6 @@ static struct passwd *check_user(const char *user)
err:
log_error("Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n", user);
#endif
return NULL;
}
@ -172,7 +186,7 @@ static int set_user(const char *user, struct passwd *user_info)
}
return 0;
}
#endif
/*
@ -188,6 +202,7 @@ static void init_environment(char *progname)
}
#ifndef __WIN__
/*
Become a UNIX service
SYNOPSYS
@ -342,3 +357,4 @@ spawn:
}
}
#endif