Commit 85834c3b authored by unknown's avatar unknown
Browse files

IM port fixes: fix crash on startup, add more error checking, get rid of unnecessary code.


server-tools/instance-manager/commands.cc:
  fix memory leak
server-tools/instance-manager/guardian.cc:
  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/guardian.h:
  prototype fixed
server-tools/instance-manager/instance_map.cc:
  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/instance_map.h:
  prototype fixed
server-tools/instance-manager/listener.cc:
  initialize highest-numbered descriptor to 0 for select before setting it with max(n, sockets[i]),
  ifdef unix-specific code
server-tools/instance-manager/manager.cc:
  remove commented stuff
server-tools/instance-manager/options.cc:
  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
parent c5bcb9f0
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -471,6 +471,7 @@ int Show_instance_log::execute(struct st_net *net, ulong connection_id)
      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 @@ int Show_instance_log::execute(struct st_net *net, ulong connection_id)

      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
+2 −12
Original line number Diff line number Diff line
@@ -424,23 +424,13 @@ int Guardian_thread::stop_instances(bool stop_instances_arg)
}


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
}
+2 −2
Original line number Diff line number Diff line
@@ -100,8 +100,8 @@ class Guardian_thread: public Guardian_thread_args
  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;
+2 −12
Original line number Diff line number Diff line
@@ -137,25 +137,15 @@ Instance_map::~Instance_map()
}


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
}


+2 −2
Original line number Diff line number Diff line
@@ -60,8 +60,8 @@ class Instance_map
  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);
Loading