List:Internals« Previous MessageNext Message »
From:Petr Chardin Date:August 5 2005 12:35pm
Subject:bk commit into 5.0 tree (petr:1.1940)
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.1940 05/08/05 14:35:30 petr@stripped +8 -0
  IM port fixes: fix crash on startup, add more error checking, get rid of unnecessary
code.

  server-tools/instance-manager/options.cc
    1.19 05/08/05 14:35:22 petr@stripped +20 -10
    fix crash in load_defaults, which happened on all Unix systems due to
    const char *Options::config_file= NULL. Check return value for GetModuleFileName.
    Get rid of obscure default_config_file[FN_REFLEN]= "/etc/my.cnf"; which was never used

  server-tools/instance-manager/manager.cc
    1.25 05/08/05 14:35:22 petr@stripped +0 -1
    remove commented stuff

  server-tools/instance-manager/listener.cc
    1.15 05/08/05 14:35:22 petr@stripped +4 -4
    initialize highest-numbered descriptor to 0 for select before setting it with max(n,
sockets[i]),
    ifdef unix-specific code

  server-tools/instance-manager/instance_map.h
    1.16 05/08/05 14:35:22 petr@stripped +2 -2
    prototype fixed

  server-tools/instance-manager/instance_map.cc
    1.22 05/08/05 14:35:22 petr@stripped +2 -12
    don't check pthread_mutex_lock/unlock status, as it never returns error if
    properly used (no self deadlocks) and initialized

  server-tools/instance-manager/guardian.h
    1.9 05/08/05 14:35:21 petr@stripped +2 -2
    prototype fixed

  server-tools/instance-manager/guardian.cc
    1.15 05/08/05 14:35:21 petr@stripped +2 -12
    don't check pthread_mutex_lock/unlock return value, as it never returns error if
properly
    used (no self deadlocks) and initialized

  server-tools/instance-manager/commands.cc
    1.29 05/08/05 14:35:21 petr@stripped +7 -3
    fix memory leak

# 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.14/server-tools/instance-manager/listener.cc	2005-08-04 01:20:17 +04:00
+++ 1.15/server-tools/instance-manager/listener.cc	2005-08-05 14:35:22 +04:00
@@ -47,6 +47,7 @@
   ~Listener_thread();
   void run();
 private:
+  static const int LISTEN_BACK_LOG_SIZE= 5;     /* standard backlog size */
   ulong total_connection_count;
   Thread_info thread_info;
 
@@ -59,7 +60,6 @@
   int   create_unix_socket(struct sockaddr_un &unix_socket_address);
 };
 
-const int LISTEN_BACK_LOG_SIZE= 5;         // standard backlog size
 
 Listener_thread::Listener_thread(const Listener_thread_args &args) :
   Listener_thread_args(args.thread_registry, args.options, args.user_map,
@@ -88,13 +88,14 @@
 
 void Listener_thread::run()
 {
+  int n= 0;
+
+#ifndef __WIN__
   /* we use this var to check whether we are running on LinuxThreads */
   pid_t thread_pid;
-  int n;
 
   thread_pid= getpid();
 
-#ifndef __WIN__
   struct sockaddr_un unix_socket_address;
   /* set global variable */
   linuxthreads= (thread_pid != manager_pid);
@@ -205,7 +206,6 @@
 #ifndef __WIN__
   int flags= fcntl(socket, F_GETFD, 0);
   fcntl(socket, F_SETFD, flags | FD_CLOEXEC);
-#else
 #endif
 }
 

--- 1.24/server-tools/instance-manager/manager.cc	2005-08-04 01:24:33 +04:00
+++ 1.25/server-tools/instance-manager/manager.cc	2005-08-05 14:35:22 +04:00
@@ -97,7 +97,6 @@
 
 int my_sigwait(const sigset_t *set, int *sig)
 {
-//  MSG msg;
   while (!have_signal)
   {
     Sleep(100);

--- 1.18/server-tools/instance-manager/options.cc	2005-08-04 18:33:35 +04:00
+++ 1.19/server-tools/instance-manager/options.cc	2005-08-05 14:35:22 +04:00
@@ -32,17 +32,16 @@
 
 const char *default_password_file_name= QUOTE(DEFAULT_PASSWORD_FILE_NAME);
 const char *default_log_file_name= QUOTE(DEFAULT_LOG_FILE_NAME);
-char default_config_file[FN_REFLEN]= "/etc/my.cnf";
+#ifdef __WIN__
+char windows_config_file[FN_REFLEN];
 
-#ifndef __WIN__
-char Options::run_as_service;
-const char *Options::user= 0;                   /* No default value */
-const char *Options::config_file= NULL;
-#else
 char Options::install_as_service;
 char Options::remove_service;
-const char *Options::config_file= QUOTE(DEFAULT_CONFIG_FILE);
+#else
+char Options::run_as_service;
+const char *Options::user= 0;                   /* No default value */
 #endif
+const char *Options::config_file= QUOTE(DEFAULT_CONFIG_FILE);
 const char *Options::log_file_name= default_log_file_name;
 const char *Options::pid_file_name= QUOTE(DEFAULT_PID_FILE_NAME);
 const char *Options::socket_file_name= QUOTE(DEFAULT_SOCKET_FILE_NAME);
@@ -271,9 +270,20 @@
   */
   if (Options::config_file == NULL)
   {
-    ::GetModuleFileName(NULL, default_config_file, sizeof(default_config_file));    char
*filename= strrchr(default_config_file, "\\");
-    strcpy(filename, "\\my.ini");
-    Options::config_file= default_config_file;
+    char *filename;
+    static const char default_win_config_file_name[]= "\\my.ini";
+
+    if (!GetModuleFileName(NULL, windows_config_file,
+                                 sizeof(windows_config_file)))
+      goto err;
+
+    filename= strrchr(windows_config_file, "\\");
+    /*
+      Don't check for the overflow as strlen("\\my.ini") is less
+      then strlen("mysqlmanager") (the binary name)
+    */
+    strcpy(filename, default_win_config_file_name);
+    Options::config_file= windows_config_file;
   }
 #endif
 

--- 1.28/server-tools/instance-manager/commands.cc	2005-08-04 18:33:34 +04:00
+++ 1.29/server-tools/instance-manager/commands.cc	2005-08-05 14:35:21 +04:00
@@ -471,6 +471,7 @@
       int read_len;
       /* calculate buffer size */
       MY_STAT file_stat;
+      Buffer read_buff;
 
       /* my_fstat doesn't use the flag parameter */
       if (my_fstat(fd, &file_stat, MYF(0)))
@@ -478,13 +479,16 @@
 
       buff_size= (size - offset);
 
+      read_buff.reserve(0, buff_size);
+
       /* read in one chunk */
       read_len= my_seek(fd, file_stat.st_size - size, MY_SEEK_SET, MYF(0));
 
-      char *bf= (char*) malloc(sizeof(char)*buff_size);
-      if ((read_len= my_read(fd, (byte*)bf, buff_size, MYF(0))) < 0)
+      if ((read_len= my_read(fd, (byte*) read_buff.buffer,
+                             buff_size, MYF(0))) < 0)
         return ER_READ_FILE;
-      store_to_protocol_packet(&send_buff, (char*) bf, &position, read_len);
+      store_to_protocol_packet(&send_buff, read_buff.buffer,
+                               &position, read_len);
       close(fd);
     }
     else

--- 1.14/server-tools/instance-manager/guardian.cc	2005-07-20 19:55:21 +04:00
+++ 1.15/server-tools/instance-manager/guardian.cc	2005-08-05 14:35:21 +04:00
@@ -424,23 +424,13 @@
 }
 
 
-int Guardian_thread::lock()
+void Guardian_thread::lock()
 {
-#ifdef __WIN__
   pthread_mutex_lock(&LOCK_guardian); 
-  return 0;
-#else
-  return pthread_mutex_lock(&LOCK_guardian);
-#endif
 }
 
 
-int Guardian_thread::unlock()
+void Guardian_thread::unlock()
 {
-#ifdef __WIN__
   pthread_mutex_unlock(&LOCK_guardian);
-  return 0;
-#else
-  return pthread_mutex_unlock(&LOCK_guardian);
-#endif
 }

--- 1.8/server-tools/instance-manager/guardian.h	2005-03-22 02:04:10 +03:00
+++ 1.9/server-tools/instance-manager/guardian.h	2005-08-05 14:35:21 +04:00
@@ -100,8 +100,8 @@
   int stop_guard(Instance *instance);
   /* Returns true if guardian thread is stopped */
   int is_stopped();
-  int lock();
-  int unlock();
+  void lock();
+  void unlock();
 
 public:
   pthread_cond_t COND_guardian;

--- 1.21/server-tools/instance-manager/instance_map.cc	2005-08-04 18:33:35 +04:00
+++ 1.22/server-tools/instance-manager/instance_map.cc	2005-08-05 14:35:22 +04:00
@@ -137,25 +137,15 @@
 }
 
 
-int Instance_map::lock()
+void Instance_map::lock()
 {
-#ifdef __WIN__
   pthread_mutex_lock(&LOCK_instance_map);
-  return 0;
-#else
-  return pthread_mutex_lock(&LOCK_instance_map);
-#endif
 }
 
 
-int Instance_map::unlock()
+void Instance_map::unlock()
 {
-#ifdef __WIN__
   pthread_mutex_unlock(&LOCK_instance_map);
-  return 0;
-#else
-  return pthread_mutex_unlock(&LOCK_instance_map);
-#endif
 }
 
 

--- 1.15/server-tools/instance-manager/instance_map.h	2005-07-21 22:40:43 +04:00
+++ 1.16/server-tools/instance-manager/instance_map.h	2005-08-05 14:35:22 +04:00
@@ -60,8 +60,8 @@
   Instance *find(const char *name, uint name_len);
 
   int flush_instances();
-  int lock();
-  int unlock();
+  void lock();
+  void unlock();
   int init();
 
   Instance_map(const char *default_mysqld_path_arg);
Thread
bk commit into 5.0 tree (petr:1.1940)Petr Chardin5 Aug