List:Internals« Previous MessageNext Message »
From:Petr Chardin Date:August 5 2005 3:02pm
Subject:bk commit into 5.0 tree (petr:1.1946)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of cps. When cps does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1946 05/08/05 17:02:06 petr@stripped +8 -0
  IM port cleanup

  server-tools/instance-manager/user_map.cc
    1.9 05/08/05 17:02:00 petr@stripped +12 -12
    simplify password file processing

  server-tools/instance-manager/options.cc
    1.20 05/08/05 17:02:00 petr@stripped +29 -28
    coding style fixes: tabs, trailing spaces, offset e.t.c

  server-tools/instance-manager/manager.cc
    1.26 05/08/05 17:02:00 petr@stripped +11 -11
    coding style fixes: tabs, trailing spaces, offset e.t.c

  server-tools/instance-manager/listener.cc
    1.16 05/08/05 17:02:00 petr@stripped +24 -23
    coding style fixes: tabs, trailing spaces, offset e.t.c

  server-tools/instance-manager/instance.cc
    1.21 05/08/05 17:02:00 petr@stripped +85 -96
    cleanup & coding style fixes: tabs, trailing spaces, offset e.t.c

  server-tools/instance-manager/WindowsService.h
    1.3 05/08/05 17:02:00 petr@stripped +4 -5
    coding style fixes: tabs, trailing spaces, offset e.t.c

  server-tools/instance-manager/WindowsService.cpp
    1.3 05/08/05 17:02:00 petr@stripped +42 -45
    coding style fixes: tabs, trailing spaces, offset e.t.c

  server-tools/instance-manager/IMService.cpp
    1.3 05/08/05 17:02:00 petr@stripped +5 -6
    coding style fixes: tabs, trailing spaces, offset e.t.c

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	petr
# Host:	owlet.
# Root:	/home/cps/mysql/trees/mysql-5.0

--- 1.15/server-tools/instance-manager/listener.cc	2005-08-05 14:35:22 +04:00
+++ 1.16/server-tools/instance-manager/listener.cc	2005-08-05 17:02:00 +04:00
@@ -108,11 +108,11 @@
   FD_ZERO(&read_fds);
 
   /* I. prepare 'listen' sockets */
-  if (create_tcp_socket()) 
+  if (create_tcp_socket())
     goto err;
 
 #ifndef __WIN__
-  if (create_unix_socket(unix_socket_address)) 
+  if (create_unix_socket(unix_socket_address))
     goto err;
 #endif
 
@@ -133,12 +133,12 @@
     int rc= select(n, &read_fds_arg, 0, 0, 0);
 
 
-      if (rc == -1 && errno != EINTR)
-      {
-        log_error("Listener_thread::run(): select() failed, %s",
-                  strerror(errno));
-        continue;
-      }
+    if (rc == -1 && errno != EINTR)
+    {
+      log_error("Listener_thread::run(): select() failed, %s",
+                strerror(errno));
+      continue;
+    }
 
 
     for (int socket_index= 0; socket_index < num_sockets; socket_index++)
@@ -150,8 +150,8 @@
         /* accept may return -1 (failure or spurious wakeup) */
         if (client_fd >= 0)                    // connection established
         {
-          Vio *vio = vio_new(client_fd, socket_index==0?VIO_TYPE_SOCKET:
-                             VIO_TYPE_TCPIP, socket_index==0?1:0);
+          Vio *vio= vio_new(client_fd, socket_index==0?VIO_TYPE_SOCKET:
+                            VIO_TYPE_TCPIP, socket_index==0?1:0);
           if (vio != 0)
             handle_new_mysql_connection(vio);
           else
@@ -212,7 +212,7 @@
 int Listener_thread::create_tcp_socket()
 {
   /* value to be set by setsockopt */
-  int arg= 1;                        
+  int arg= 1;
 
   int ip_socket= socket(AF_INET, SOCK_STREAM, 0);
   if (ip_socket == INVALID_SOCKET)
@@ -236,11 +236,11 @@
   uint im_port= options.port_number;
 
   ip_socket_address.sin_family= AF_INET;
-  ip_socket_address.sin_addr.s_addr = im_bind_addr;
+  ip_socket_address.sin_addr.s_addr= im_bind_addr;
 
 
   ip_socket_address.sin_port= (unsigned short)
-                              htons((unsigned short) im_port);
+    htons((unsigned short) im_port);
 
   setsockopt(ip_socket, SOL_SOCKET, SO_REUSEADDR, (char*) &arg, sizeof(arg));
   if (bind(ip_socket, (struct sockaddr *) &ip_socket_address,
@@ -273,8 +273,8 @@
 }
 
 #ifndef __WIN__
-int Listener_thread::create_unix_socket(
-			struct sockaddr_un &unix_socket_address)
+int Listener_thread::create_unix_socket(struct sockaddr_un
+                                        &unix_socket_address)
 {
   int unix_socket= socket(AF_UNIX, SOCK_STREAM, 0);
   if (unix_socket == INVALID_SOCKET)
@@ -297,20 +297,20 @@
   */
   mode_t old_mask= umask(0);
   if (bind(unix_socket, (struct sockaddr *) &unix_socket_address,
-            sizeof(unix_socket_address)))
+           sizeof(unix_socket_address)))
   {
     log_error("Listener_thread::run(): bind(unix socket) failed, "
-                "socket file name is '%s', error '%s'",
-                unix_socket_address.sun_path, strerror(errno));
+              "socket file name is '%s', error '%s'",
+              unix_socket_address.sun_path, strerror(errno));
     close(unix_socket);
     return -1;
   }
-  
+
   umask(old_mask);
-  
+
   if (listen(unix_socket, LISTEN_BACK_LOG_SIZE))
   {
-    log_error("Listener_thread::run(): listen(unix socket) failed, %s", 
+    log_error("Listener_thread::run(): listen(unix socket) failed, %s",
               strerror(errno));
     close(unix_socket);
     return -1;
@@ -322,8 +322,9 @@
   /* make sure that instances won't be listening our sockets */
   set_no_inherit(unix_socket);
 
-  log_info("accepting connections on unix socket %s", unix_socket_address.sun_path);
-  sockets[num_sockets++] = unix_socket;
+  log_info("accepting connections on unix socket %s",
+           unix_socket_address.sun_path);
+  sockets[num_sockets++]= unix_socket;
   FD_SET(unix_socket, &read_fds);
   return 0;
 }

--- 1.25/server-tools/instance-manager/manager.cc	2005-08-05 14:35:22 +04:00
+++ 1.26/server-tools/instance-manager/manager.cc	2005-08-05 17:02:00 +04:00
@@ -238,20 +238,20 @@
       process_alarm(signo);
     else
 #endif
+    {
+      if (!guardian_thread.is_stopped())
       {
-        if (!guardian_thread.is_stopped())
-        {
-          bool stop_instances= true;
-          guardian_thread.request_shutdown(stop_instances);
-          pthread_cond_signal(&guardian_thread.COND_guardian);
-        }
-        else
-        {
-          thread_registry.deliver_shutdown();
-          shutdown_complete= TRUE;
-        }
+        bool stop_instances= true;
+        guardian_thread.request_shutdown(stop_instances);
+        pthread_cond_signal(&guardian_thread.COND_guardian);
+      }
+      else
+      {
+        thread_registry.deliver_shutdown();
+        shutdown_complete= TRUE;
       }
     }
+  }
 
 err:
   /* delete the pid file */

--- 1.19/server-tools/instance-manager/options.cc	2005-08-05 14:35:22 +04:00
+++ 1.20/server-tools/instance-manager/options.cc	2005-08-05 17:02:00 +04:00
@@ -111,22 +111,23 @@
     0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
 
   { "default-mysqld-path", OPT_MYSQLD_PATH, "Where to look for MySQL"
-                                            " Server binary.",
-    (gptr *) &Options::default_mysqld_path, (gptr *)
&Options::default_mysqld_path,
+    " Server binary.",
+    (gptr *) &Options::default_mysqld_path,
+    (gptr *) &Options::default_mysqld_path,
     0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
 
-  { "monitoring-interval", OPT_MONITORING_INTERVAL, "Interval to monitor instances"
-                                            " in seconds.",
-                   (gptr *) &Options::monitoring_interval,
-                   (gptr *) &Options::monitoring_interval,
-                   0, GET_UINT, REQUIRED_ARG, DEFAULT_MONITORING_INTERVAL,
-                   0, 0, 0, 0, 0 },
+  { "monitoring-interval", OPT_MONITORING_INTERVAL, "Interval to monitor"
+    " instances in seconds.",
+    (gptr *) &Options::monitoring_interval,
+    (gptr *) &Options::monitoring_interval,
+    0, GET_UINT, REQUIRED_ARG, DEFAULT_MONITORING_INTERVAL,
+    0, 0, 0, 0, 0 },
 #ifdef __WIN__
-  { "install", OPT_INSTALL_SERVICE, "Install as system service.", 
-    (gptr *) &Options::install_as_service, (gptr*) &Options::install_as_service, 
+  { "install", OPT_INSTALL_SERVICE, "Install as system service.",
+    (gptr *) &Options::install_as_service, (gptr*) &Options::install_as_service,
     0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 },
-  { "remove", OPT_REMOVE_SERVICE, "Remove system service.", 
-  (gptr *)&Options::remove_service, (gptr*) &Options::remove_service, 
+  { "remove", OPT_REMOVE_SERVICE, "Remove system service.",
+    (gptr *)&Options::remove_service, (gptr*) &Options::remove_service,
     0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0},
 #else
   { "run-as-service", OPT_RUN_AS_SERVICE,
@@ -134,12 +135,12 @@
     0, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 },
 
   { "user", OPT_USER, "Username to start mysqlmanager",
-                   (gptr *) &Options::user,
-                   (gptr *) &Options::user,
-                   0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+    (gptr *) &Options::user,
+    (gptr *) &Options::user,
+    0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
 #endif
   { "version", 'V', "Output version information and exit.", 0, 0, 0,
-   GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
+    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
 
   { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }
 };
@@ -242,7 +243,7 @@
 int Options::load(int argc, char **argv)
 {
   saved_argv= argv;
-  
+
   if (argc >= 2)
   {
     if (is_prefix(argv[1], "--defaults-file="))
@@ -254,19 +255,19 @@
     {
       /* the log is not enabled yet */
       fprintf(stderr, "The --defaults-extra-file and --no-defaults options"
-                      " are not supported by\n"
-                      "Instance Manager. Program aborted.\n");
+              " are not supported by\n"
+              "Instance Manager. Program aborted.\n");
       goto err;
     }
   }
 
 #ifdef __WIN__
   setup_windows_defaults(*argv);
-  
-  /* 
-     On Windows, there are two possibilities.  Either we are given
-     a defaults file on the command line or we use the my.ini file
-     that is in our app dir
+
+  /*
+    On Windows, there are two possibilities.  Either we are given
+    a defaults file on the command line or we use the my.ini file
+    that is in our app dir
   */
   if (Options::config_file == NULL)
   {
@@ -274,7 +275,7 @@
     static const char default_win_config_file_name[]= "\\my.ini";
 
     if (!GetModuleFileName(NULL, windows_config_file,
-                                 sizeof(windows_config_file)))
+                           sizeof(windows_config_file)))
       goto err;
 
     filename= strrchr(windows_config_file, "\\");
@@ -316,7 +317,7 @@
 {
   char *dot= (char*)strrchr(src, '.');
   if (!dot) return (char*)src;
-  
+
   int newlen= dot-src+strlen(newext)+1;
   char *temp= (char*)malloc(newlen);
   bzero(temp, newlen);
@@ -327,9 +328,9 @@
 
 void Options::setup_windows_defaults(const char *progname)
 {
-  Options::password_file_name= default_password_file_name = 
+  Options::password_file_name= default_password_file_name=
     change_extension(progname, "passwd");
-  Options::log_file_name= default_log_file_name = 
+  Options::log_file_name= default_log_file_name=
     change_extension(progname, "log");
 }
 

--- 1.20/server-tools/instance-manager/instance.cc	2005-08-04 01:20:16 +04:00
+++ 1.21/server-tools/instance-manager/instance.cc	2005-08-05 17:02:00 +04:00
@@ -57,12 +57,12 @@
 
 void Instance::remove_pid()
 {
-    int pid;
-    if ((pid= options.get_pid()) != 0)          /* check the pidfile */
-      if (options.unlink_pidfile())             /* remove stalled pidfile */
-        log_error("cannot remove pidfile for instance %i, this might be \
-                  since IM lacks permmissions or hasn't found the pidifle",
-                  options.instance_name);
+  int pid;
+  if ((pid= options.get_pid()) != 0)          /* check the pidfile */
+    if (options.unlink_pidfile())             /* remove stalled pidfile */
+      log_error("cannot remove pidfile for instance %i, this might be \
+                since IM lacks permmissions or hasn't found the pidifle",
+                options.instance_name);
 }
 
 /*
@@ -121,16 +121,15 @@
 {
   pid_t pid= fork();
 
-  switch (pid)
-  {
-    case 0:
-      execv(options.mysqld_path, options.argv);
-      /* exec never returns */
-      exit(1);
-    case -1:
-      log_info("cannot fork() to start instance %s", options.instance_name);
-      return -1;
-    default:
+  switch (pid) {
+  case 0:
+    execv(options.mysqld_path, options.argv);
+    /* exec never returns */
+    exit(1);
+  case -1:
+    log_info("cannot fork() to start instance %s", options.instance_name);
+    return -1;
+  default:
     /*
       Here we wait for the child created. This process differs for systems
       running LinuxThreads and POSIX Threads compliant systems. This is because
@@ -157,56 +156,56 @@
 #else
 int Instance::launch_and_wait()
 {
-    STARTUPINFO si;
-    PROCESS_INFORMATION pi;
+  STARTUPINFO si;
+  PROCESS_INFORMATION pi;
 
-    ZeroMemory(&si, sizeof(si));
-    si.cb = sizeof(si);
-    ZeroMemory(&pi, sizeof(pi));
+  ZeroMemory(&si, sizeof(si));
+  si.cb= sizeof(si);
+  ZeroMemory(&pi, sizeof(pi));
+
+  int cmdlen= 0;
+  for (int i= 1; options.argv[i] != 0; i++)
+    cmdlen+= strlen(options.argv[i]) + 1;
+  cmdlen++;  // we have to add a single space for CreateProcess (read the docs)
 
-    int cmdlen= 0;
+  char *cmdline= NULL;
+  if (cmdlen > 0)
+  {
+    cmdline= new char[cmdlen];
+    cmdline[0]= 0;
     for (int i= 1; options.argv[i] != 0; i++)
-      cmdlen+= strlen(options.argv[i]) + 1;
-    cmdlen++;  // we have to add a single space for CreateProcess (read the docs)
-
-    char *cmdline= NULL;
-    if (cmdlen > 0)
     {
-      cmdline= new char[cmdlen];
-      cmdline[0]= 0;
-      for (int i= 1; options.argv[i] != 0; i++)
-      {
-        strcat(cmdline, " ");
-        strcat(cmdline, options.argv[i]);
-      }
+      strcat(cmdline, " ");
+      strcat(cmdline, options.argv[i]);
     }
+  }
 
-    // Start the child process. 
-    BOOL result= CreateProcess(options.mysqld_path,    // file to execute 
-                 cmdline,    // Command line. 
-                 NULL,       // Process handle not inheritable. 
-                 NULL,       // Thread handle not inheritable. 
-                 FALSE,      // Set handle inheritance to FALSE. 
-                 0,          // No creation flags. 
-                 NULL,       // Use parent's environment block. 
-                 NULL,       // Use parent's starting directory. 
-                 &si,        // Pointer to STARTUPINFO structure.
-                 &pi );      // Pointer to PROCESS_INFORMATION structure.
-    delete cmdline;
-    if (! result)
-      return -1;
-    
-    // Wait until child process exits.
-    WaitForSingleObject(pi.hProcess, INFINITE);
-
-    DWORD exitcode;
-    ::GetExitCodeProcess(pi.hProcess, &exitcode);
-
-    // Close process and thread handles. 
-    CloseHandle(pi.hProcess);
-    CloseHandle(pi.hThread);
+  // Start the child process.
+  BOOL result= CreateProcess(options.mysqld_path,    // file to execute
+                             cmdline,    // Command line.
+                             NULL,       // Process handle not inheritable.
+                             NULL,       // Thread handle not inheritable.
+                             FALSE,      // Set handle inheritance to FALSE.
+                             0,          // No creation flags.
+                             NULL,       // Use parent's environment block.
+                             NULL,       // Use parent's starting directory.
+                             &si,        // Pointer to STARTUPINFO structure.
+                             &pi );      // Pointer to PROCESS_INFORMATION structure.
+  delete cmdline;
+  if (! result)
+    return -1;
+
+  // Wait until child process exits.
+  WaitForSingleObject(pi.hProcess, INFINITE);
+
+  DWORD exitcode;
+  ::GetExitCodeProcess(pi.hProcess, &exitcode);
+
+  // Close process and thread handles.
+  CloseHandle(pi.hProcess);
+  CloseHandle(pi.hThread);
 
-    return exitcode;
+  return exitcode;
 }
 #endif
 
@@ -214,9 +213,9 @@
 void Instance::fork_and_monitor()
 {
   log_info("starting instance %s", options.instance_name);
-  
-  int result= launch_and_wait();
-  if (result == -1) return;
+
+  if (launch_and_wait())
+    return;                                     /* error is logged */
 
   /* set instance state to crashed */
   pthread_mutex_lock(&LOCK_instance);
@@ -233,9 +232,6 @@
   pthread_cond_signal(&instance_map->guardian->COND_guardian);
   /* thread exits */
   return;
-
-  /* we should never end up here */
-  DBUG_ASSERT(0);
 }
 
 
@@ -268,9 +264,9 @@
   MYSQL mysql;
   uint port= 0;
   const char *socket= NULL;
-  const char *password= "check_connection";
-  const char *username= "MySQL_Instance_Manager";
-  const char *access_denied_message= "Access denied for user";
+  static const char *password= "check_connection";
+  static const char *username= "MySQL_Instance_Manager";
+  static const char *access_denied_message= "Access denied for user";
   bool return_val;
 
   if (options.mysqld_port)
@@ -299,15 +295,8 @@
     return_val= TRUE;                           /* server is alive */
   }
   else
-  {
-    if (!strncmp(access_denied_message, mysql_error(&mysql),
-                 sizeof(access_denied_message)-1))
-    {
-      return_val= TRUE;
-    }
-    else
-      return_val= FALSE;
-  }
+    return_val= test(!strncmp(access_denied_message, mysql_error(&mysql),
+                              sizeof(access_denied_message) - 1));
 
   mysql_close(&mysql);
   pthread_mutex_unlock(&LOCK_instance);
@@ -370,53 +359,53 @@
 
 BOOL SafeTerminateProcess(HANDLE hProcess, UINT uExitCode)
 {
-  DWORD dwTID, dwCode, dwErr = 0;
+  DWORD dwTID, dwCode, dwErr= 0;
   HANDLE hProcessDup= INVALID_HANDLE_VALUE;
   HANDLE hRT= NULL;
   HINSTANCE hKernel= GetModuleHandle("Kernel32");
   BOOL bSuccess= FALSE;
 
   BOOL bDup= DuplicateHandle(GetCurrentProcess(),
-                             hProcess, GetCurrentProcess(), &hProcessDup, 
+                             hProcess, GetCurrentProcess(), &hProcessDup,
                              PROCESS_ALL_ACCESS, FALSE, 0);
 
   // Detect the special case where the process is
   // already dead...
   if (GetExitCodeProcess((bDup) ? hProcessDup : hProcess, &dwCode) &&
-    (dwCode == STILL_ACTIVE))
+      (dwCode == STILL_ACTIVE))
   {
-      FARPROC pfnExitProc;
+    FARPROC pfnExitProc;
 
-      pfnExitProc= GetProcAddress(hKernel, "ExitProcess");
+    pfnExitProc= GetProcAddress(hKernel, "ExitProcess");
 
-      hRT= CreateRemoteThread((bDup) ? hProcessDup : hProcess, NULL, 0,
-                              (LPTHREAD_START_ROUTINE)pfnExitProc, 
-                              (PVOID)uExitCode, 0, &dwTID);
+    hRT= CreateRemoteThread((bDup) ? hProcessDup : hProcess, NULL, 0,
+                            (LPTHREAD_START_ROUTINE)pfnExitProc,
+                            (PVOID)uExitCode, 0, &dwTID);
 
-      if (hRT == NULL)
-          dwErr= GetLastError();
+    if (hRT == NULL)
+      dwErr= GetLastError();
   }
   else
-      dwErr= ERROR_PROCESS_ABORTED;
+    dwErr= ERROR_PROCESS_ABORTED;
 
   if (hRT)
   {
-      // Must wait process to terminate to
-      // guarantee that it has exited...
-      WaitForSingleObject((bDup) ? hProcessDup : hProcess, INFINITE);
+    // Must wait process to terminate to
+    // guarantee that it has exited...
+    WaitForSingleObject((bDup) ? hProcessDup : hProcess, INFINITE);
 
-      CloseHandle(hRT);
-      bSuccess= TRUE;
+    CloseHandle(hRT);
+    bSuccess= TRUE;
   }
 
   if (bDup)
-      CloseHandle(hProcessDup);
+    CloseHandle(hProcessDup);
 
   if (!bSuccess)
-      SetLastError(dwErr);
+    SetLastError(dwErr);
 
   return bSuccess;
-} 
+}
 
 int kill(pid_t pid, int signum)
 {

--- 1.8/server-tools/instance-manager/user_map.cc	2005-08-04 01:20:18 +04:00
+++ 1.9/server-tools/instance-manager/user_map.cc	2005-08-05 17:02:00 +04:00
@@ -15,7 +15,7 @@
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #ifdef __GNUC__
-#pragma interface 
+#pragma interface
 #endif
 
 #include "user_map.h"
@@ -25,6 +25,12 @@
 
 #include "log.h"
 
+#ifdef __WIN__
+#define NEWLINE_LEN 2
+#else
+#define NEWLINE_LEN 1
+#endif
+
 struct User
 {
   char user[USERNAME_LENGTH + 1];
@@ -36,8 +42,7 @@
 
 int User::init(const char *line)
 {
-  const char *name_begin, *name_end;
-  char *password;
+  const char *name_begin, *name_end, *password;
 
   if (line[0] == '\'' || line[0] == '"')
   {
@@ -45,7 +50,7 @@
     name_end= strchr(name_begin, line[0]);
     if (name_end == 0 || name_end[1] != ':')
       goto err;
-    password= (char*)(name_end + 2);
+    password= name_end + 2;
   }
   else
   {
@@ -53,19 +58,14 @@
     name_end= strchr(name_begin, ':');
     if (name_end == 0)
       goto err;
-    password= (char*)(name_end + 1);
+    password= name_end + 1;
   }
   user_length= name_end - name_begin;
   if (user_length > USERNAME_LENGTH)
     goto err;
 
   /* assume that newline characater is present */
-  if (password[strlen(password)-2] == '\r')
-  {
-    password[strlen(password)-2]= '\n';
-    password[strlen(password)-1]= 0;
-  }
-  if (strlen(password) != SCRAMBLED_PASSWORD_CHAR_LENGTH + 1)
+  if (strlen(password) != SCRAMBLED_PASSWORD_CHAR_LENGTH + NEWLINE_LEN)
     goto err;
 
   memcpy(user, name_begin, user_length);
@@ -101,7 +101,7 @@
 
 int User_map::init()
 {
-  enum { START_HASH_SIZE = 16 };
+  enum { START_HASH_SIZE= 16 };
   if (hash_init(&hash, default_charset_info, START_HASH_SIZE, 0, 0,
       get_user_key, delete_user, 0))
     return 1;

--- 1.2/server-tools/instance-manager/IMService.cpp	2005-08-04 01:20:15 +04:00
+++ 1.3/server-tools/instance-manager/IMService.cpp	2005-08-05 17:02:00 +04:00
@@ -5,8 +5,8 @@
 
 IMService::IMService(void)
 {
-  serviceName = "MySqlManager";
-  displayName = "MySQL Manager";
+  serviceName= "MySqlManager";
+  displayName= "MySQL Manager";
 }
 
 IMService::~IMService(void)
@@ -35,13 +35,13 @@
   log_info(msg);
 }
 
-int HandleServiceOptions(Options options) 
+int HandleServiceOptions(Options options)
 {
   int ret_val= 0;
 
   IMService winService;
 
-  if (options.install_as_service) 
+  if (options.install_as_service)
   {
     if (winService.IsInstalled())
       log_info("Service is already installed\n");
@@ -59,7 +59,7 @@
       log_info("Service is not installed\n");
     else if (winService.Remove())
       log_info("Service removed successfully\n");
-    else 
+    else
     {
       log_info("Service failed to remove\n");
       ret_val= -1;
@@ -69,4 +69,3 @@
     return (int)winService.Init();
   return ret_val;
 }
-

--- 1.2/server-tools/instance-manager/WindowsService.cpp	2005-08-04 01:20:15 +04:00
+++ 1.3/server-tools/instance-manager/WindowsService.cpp	2005-08-05 17:02:00 +04:00
@@ -4,9 +4,9 @@
 
 static WindowsService *gService;
 
-WindowsService::WindowsService(void) : 
-  statusCheckpoint(0), 
-  serviceName(NULL), 
+WindowsService::WindowsService(void) :
+  statusCheckpoint(0),
+  serviceName(NULL),
   inited(false),
   dwAcceptedControls(SERVICE_ACCEPT_STOP)
 {
@@ -32,14 +32,14 @@
   GetModuleFileName(NULL, szFilePath, sizeof(szFilePath));
 
   // open a connection to the SCM
-  if (!(scm= OpenSCManager(0, 0,SC_MANAGER_CREATE_SERVICE))) 
+  if (!(scm= OpenSCManager(0, 0,SC_MANAGER_CREATE_SERVICE)))
     return false;
 
   newService= CreateService(scm, serviceName, displayName,
-                             SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, 
-                             SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, 
-                             szFilePath, NULL, NULL, NULL, username, 
-                             password);
+                            SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
+                            SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
+                            szFilePath, NULL, NULL, NULL, username,
+                            password);
 
   if (newService)
   {
@@ -68,7 +68,7 @@
 
 BOOL WindowsService::Remove()
 {
-  bool	ret_val= false;
+  bool  ret_val= false;
 
   if (! IsInstalled())
     return true;
@@ -81,7 +81,7 @@
   SC_HANDLE service= OpenService(scm, serviceName, DELETE);
   if (service)
   {
-    if (DeleteService(service)) 
+    if (DeleteService(service))
       ret_val= true;
     DWORD dw= ::GetLastError();
     CloseServiceHandle(service);
@@ -112,18 +112,18 @@
 }
 
 
-BOOL WindowsService::ReportStatus(DWORD currentState, DWORD waitHint, 
+BOOL WindowsService::ReportStatus(DWORD currentState, DWORD waitHint,
                                   DWORD dwError)
 {
   if(debugging) return TRUE;
 
   if(currentState == SERVICE_START_PENDING)
-      status.dwControlsAccepted= 0;
+    status.dwControlsAccepted= 0;
   else
-      status.dwControlsAccepted= dwAcceptedControls;
+    status.dwControlsAccepted= dwAcceptedControls;
 
   status.dwCurrentState= currentState;
-  status.dwWin32ExitCode= dwError != 0 ? 
+  status.dwWin32ExitCode= dwError != 0 ?
     ERROR_SERVICE_SPECIFIC_ERROR : NO_ERROR;
   status.dwWaitHint= waitHint;
   status.dwServiceSpecificExitCode= dwError;
@@ -155,35 +155,34 @@
 void WindowsService::HandleControlCode(DWORD opcode)
 {
   // Handle the requested control code.
-  switch(opcode)
-  {
-    case SERVICE_CONTROL_STOP:
-      // Stop the service.
-      status.dwCurrentState= SERVICE_STOP_PENDING;
-      Stop();
-      break;
-
-    case SERVICE_CONTROL_PAUSE:
-      status.dwCurrentState= SERVICE_PAUSE_PENDING;
-      Pause();
-      break;
-
-    case SERVICE_CONTROL_CONTINUE:
-      status.dwCurrentState= SERVICE_CONTINUE_PENDING;
-      Continue();
-      break;
-
-    case SERVICE_CONTROL_SHUTDOWN:
-      Shutdown();
-      break;
-
-    case SERVICE_CONTROL_INTERROGATE:
-      ReportStatus(status.dwCurrentState);
-      break;
-
-    default:
-      // invalid control code
-      break;
+  switch(opcode) {
+  case SERVICE_CONTROL_STOP:
+    // Stop the service.
+    status.dwCurrentState= SERVICE_STOP_PENDING;
+    Stop();
+    break;
+
+  case SERVICE_CONTROL_PAUSE:
+    status.dwCurrentState= SERVICE_PAUSE_PENDING;
+    Pause();
+    break;
+
+  case SERVICE_CONTROL_CONTINUE:
+    status.dwCurrentState= SERVICE_CONTINUE_PENDING;
+    Continue();
+    break;
+
+  case SERVICE_CONTROL_SHUTDOWN:
+    Shutdown();
+    break;
+
+  case SERVICE_CONTROL_INTERROGATE:
+    ReportStatus(status.dwCurrentState);
+    break;
+
+  default:
+    // invalid control code
+    break;
   }
 }
 
@@ -201,5 +200,3 @@
 
   return gService->HandleControlCode(opcode);
 }
-
-

--- 1.2/server-tools/instance-manager/WindowsService.h	2005-08-04 01:20:16 +04:00
+++ 1.3/server-tools/instance-manager/WindowsService.h	2005-08-05 17:02:00 +04:00
@@ -3,7 +3,7 @@
 class WindowsService
 {
 protected:
-  bool	                inited;
+  bool                  inited;
   const char            *serviceName;
   const char            *displayName;
   const char            *username;
@@ -23,11 +23,11 @@
   BOOL  Init();
   BOOL  IsInstalled();
   void  SetAcceptedControls(DWORD acceptedControls);
-  void  Debug(bool debugFlag) { debugging = debugFlag; }
+  void  Debug(bool debugFlag) { debugging= debugFlag; }
 
 public:
-  static void WINAPI	ServiceMain(DWORD argc, LPTSTR *argv);
-  static void WINAPI	ControlHandler(DWORD CtrlType);
+  static void WINAPI    ServiceMain(DWORD argc, LPTSTR *argv);
+  static void WINAPI    ControlHandler(DWORD CtrlType);
 
 protected:
   virtual void Run()= 0;
@@ -41,4 +41,3 @@
   void HandleControlCode(DWORD opcode);
   void RegisterAndRun(DWORD argc, LPTSTR *argv);
 };
-
Thread
bk commit into 5.0 tree (petr:1.1946)Petr Chardin5 Aug