List:Internals« Previous MessageNext Message »
From:konstantin Date:August 21 2003 10:58pm
Subject:bk commit into 5.0 tree (1.1567)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kostja. When kostja 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://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
  1.1567 03/08/22 00:58:40 kostja@stripped +11 -0
  comment fixes, Dima's review included

  server-tools/instance-manager/thread_repository.cc
    1.3 03/08/22 00:58:37 kostja@stripped +9 -2
    more comments

  server-tools/instance-manager/options.h
    1.3 03/08/22 00:58:37 kostja@stripped +1 -1
    minor comment fixes

  server-tools/instance-manager/options.cc
    1.3 03/08/22 00:58:37 kostja@stripped +1 -1
    minor comment fixes

  server-tools/instance-manager/mysqlmanager.cc
    1.4 03/08/22 00:58:37 kostja@stripped +13 -7
    comment fixes, Dima's rewview included

  server-tools/instance-manager/mysql_connection.h
    1.2 03/08/22 00:58:37 kostja@stripped +1 -1
    minor comment fixes

  server-tools/instance-manager/mysql_connection.cc
    1.2 03/08/22 00:58:37 kostja@stripped +4 -2
    mcomment fixes

  server-tools/instance-manager/manager.cc
    1.4 03/08/22 00:58:37 kostja@stripped +14 -2
    minor comment fixes

  server-tools/instance-manager/log.h
    1.3 03/08/22 00:58:37 kostja@stripped +3 -6
    comment fixes

  server-tools/instance-manager/log.cc
    1.2 03/08/22 00:58:37 kostja@stripped +2 -2
    minor comment fixes

  server-tools/instance-manager/listener.h
    1.3 03/08/22 00:58:37 kostja@stripped +1 -1
    style fix

  server-tools/instance-manager/listener.cc
    1.3 03/08/22 00:58:37 kostja@stripped +11 -5
    style fixes, Dima review notes included

# 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:	kostja
# Host:	oak.local
# Root:	/home/kostja/mysql/mysql-5.0-im

--- 1.2/server-tools/instance-manager/listener.cc	Thu Aug 21 00:37:38 2003
+++ 1.3/server-tools/instance-manager/listener.cc	Fri Aug 22 00:58:37 2003
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -41,6 +41,8 @@
   Using 'die' in case of syscall failure is OK now - we don't hold any
   resources and 'die' kills the signal thread automatically. To be rewritten
   one day.
+  See also comments in mysqlmanager.cc to picture general Instance Manager
+  architecture.
 */
 
 pthread_handler_decl(listener, arg)
@@ -72,7 +74,7 @@
     mode_t old_mask= umask(0);         
     if (bind(unix_socket, (struct sockaddr *) &unix_socket_address,
              sizeof(unix_socket_address)))
-      die("lisener(): bind(unix socket) failed, socket file name is %s, %s",
+      die("listener(): bind(unix socket) failed, socket file name is %s, %s",
           unix_socket_address.sun_path, strerror(errno));
     umask(old_mask);
     
@@ -99,7 +101,7 @@
     while (thread_repository.is_shutdown() == false)
     {
       fd_set read_fds_arg= read_fds;
-      int rc= select(max_fd_no, &read_fds_arg, 0, 0, 0);
+      int rc= select(max_fd_no + 1, &read_fds_arg, 0, 0, 0);
       if (rc == -1 && errno != EINTR)
         log_error("listener(): select() failed, %s", strerror(errno));
       else
@@ -108,8 +110,8 @@
         if (FD_ISSET(unix_socket, &read_fds_arg))
         {
           int client_fd= accept(unix_socket, 0, 0);
-          /* accept may return -1 (failure), or 0 (spurious wakeup) */
-          if (client_fd > 0)                    // connection established
+          /* accept may return -1 (failure or spurious wakeup) */
+          if (client_fd >= 0)                    // connection established
           {
             if (Vio *vio= vio_new(client_fd, VIO_TYPE_SOCKET, 1))
               handle_new_mysql_connection(vio, args);
@@ -149,6 +151,10 @@
   if (Mysql_connection_thread_args *mysql_thread_args=
       new Mysql_connection_thread_args(vio, args->thread_repository))
   {
+    /*
+      Initialize thread attributes to create detached thread; it seems
+      easier to do it ad-hoc than have a global variable.
+    */
     pthread_t mysql_thd_id;
     pthread_attr_t mysql_thd_attr;
     pthread_attr_init(&mysql_thd_attr);

--- 1.2/server-tools/instance-manager/listener.h	Thu Aug 21 00:37:38 2003
+++ 1.3/server-tools/instance-manager/listener.h	Fri Aug 22 00:58:37 2003
@@ -1,6 +1,6 @@
 #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_LISTENER_H
 #define INCLUDES_MYSQL_INSTANCE_MANAGER_LISTENER_H
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

--- 1.1/server-tools/instance-manager/log.cc	Sat Aug 16 21:44:00 2003
+++ 1.2/server-tools/instance-manager/log.cc	Fri Aug 22 00:58:37 2003
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -139,7 +139,7 @@
 }
 
 /*
-    init_logs()
+    log_init()
   RETURN VALUE
     0 ok
    !0 error

--- 1.2/server-tools/instance-manager/log.h	Tue Aug 19 19:55:18 2003
+++ 1.3/server-tools/instance-manager/log.h	Fri Aug 22 00:58:37 2003
@@ -1,6 +1,6 @@
 #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_LOG_H
 #define INCLUDES_MYSQL_INSTANCE_MANAGER_LOG_H
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -22,11 +22,8 @@
   Two logging streams are supported: error log and info log. Additionally
   libdbug may be used for debug information output.
   ANSI C buffered I/O is used to perform logging.
-  Logging may be performed in two modes: 
-  - console application mode (default), stdout/stderr is used for logging
-  init_logs() must be called to initialize logging environment
-  - daemon mode, without controlling terminal, call
-  init_logs_in_daemon_mode() to initialize
+  Logging is performed via stdout/stder, so one can reopen them to point to
+  ordinary files. To initialize loggin environment log_init() must be called.
   
   Rationale:
   - no MYSQL_LOG as it has BIN mode, and not easy to fetch from sql_class.h

--- 1.3/server-tools/instance-manager/manager.cc	Tue Aug 19 20:00:34 2003
+++ 1.4/server-tools/instance-manager/manager.cc	Fri Aug 22 00:58:37 2003
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -24,6 +24,13 @@
 #include "log.h"
 
 
+/*
+  manager - entry point to the main instance manager process: start
+  listener thread, write pid file and enter into signal handling.
+  See also comments in mysqlmanager.cc to picture general Instance Manager
+  architecture.
+*/
+
 void manager(const char *socket_file_name)
 {
   Thread_repository thread_repository;
@@ -40,8 +47,9 @@
 
   /* all new threads will inherite this signal mask */
   pthread_sigmask(SIG_BLOCK, &mask, NULL);
+    
+  /* create the listener */
   {
-    /* create the listener */
     pthread_t listener_thd_id;
     pthread_attr_t listener_thd_attr;
 
@@ -58,5 +66,9 @@
   int signo;
   sigwait(&mask, &signo);
   thread_repository.deliver_shutdown();
+
+  /* delete the pid file */
+
   /* don't pthread_exit to kill all threads who did not shut down in time */
 }
+

--- 1.1/server-tools/instance-manager/mysql_connection.cc	Thu Aug 21 00:37:38 2003
+++ 1.2/server-tools/instance-manager/mysql_connection.cc	Fri Aug 22 00:58:37 2003
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -30,7 +30,9 @@
 C_MODE_START
 
 /*
-  MySQL connection - handle connection with mysql command line client
+  MySQL connection - handle one connection with mysql command line client
+  See also comments in mysqlmanager.cc to picture general Instance Manager
+  architecture.
 */
 
 pthread_handler_decl(mysql_connection, arg)

--- 1.1/server-tools/instance-manager/mysql_connection.h	Thu Aug 21 00:37:38 2003
+++ 1.2/server-tools/instance-manager/mysql_connection.h	Fri Aug 22 00:58:37 2003
@@ -1,6 +1,6 @@
 #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_MYSQL_CONNECTION_H
 #define INCLUDES_MYSQL_INSTANCE_MANAGER_MYSQL_CONNECTION_H
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

--- 1.3/server-tools/instance-manager/mysqlmanager.cc	Thu Aug 21 00:37:38 2003
+++ 1.4/server-tools/instance-manager/mysqlmanager.cc	Fri Aug 22 00:58:37 2003
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 #include "log.h"
 
 /*
-  Few notes about the Instance Manager architecture:
+  Few notes about Instance Manager architecture:
   Instance Manager consisits of two processes: the angel process, and the
   instance manager process. Responsibilities of the angel process is to
   monitor the instance manager process, and restart it in case of
@@ -68,11 +68,12 @@
   options.load(argc, argv);
   if (options.run_as_service)
   {
+    /* forks, and return only in child */
     daemonize(options.log_file_name);
+    /* forks, and returns only in child */
     angel(options);
   }
-  else
-    manager(options.socket_file_name);
+  manager(options.socket_file_name);
   return 0;
 }
 
@@ -223,8 +224,8 @@
     sigaction(SIGTERM, &sa_term_out, 0);
     sigaction(SIGINT, &sa_int_out, 0);
     sigaction(SIGHUP, &sa_hup_out, 0);
-
-    manager(options.socket_file_name);
+    /* Here we return to main, and fall into manager */
+    break;
   default:                                    // parent, success
     while (child_status == CHILD_OK && is_terminated == 0)
       sigsuspend(&zeromask);
@@ -239,6 +240,11 @@
       sleep(1); /* don't respawn too fast */
       goto spawn;
     }
-    /* mysqlmanager successfully exited, let's silently evaporate */
+    /*
+      mysqlmanager successfully exited, let's silently evaporate
+      We can't return to main not to fall into the manager function
+    */
+    exit(0);
   }
 }
+

--- 1.2/server-tools/instance-manager/options.cc	Tue Aug 19 19:55:18 2003
+++ 1.3/server-tools/instance-manager/options.cc	Fri Aug 22 00:58:37 2003
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

--- 1.2/server-tools/instance-manager/options.h	Tue Aug 19 19:55:18 2003
+++ 1.3/server-tools/instance-manager/options.h	Fri Aug 22 00:58:37 2003
@@ -1,6 +1,6 @@
 #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_OPTIONS_H
 #define INCLUDES_MYSQL_INSTANCE_MANAGER_OPTIONS_H
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

--- 1.2/server-tools/instance-manager/thread_repository.cc	Thu Aug 21 00:37:38 2003
+++ 1.3/server-tools/instance-manager/thread_repository.cc	Fri Aug 22 00:58:37 2003
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+/* Copyright (C) 2003 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -160,6 +160,13 @@
     if (info->current_cond)
       pthread_cond_signal(info->current_cond);
   }
+  /* 
+    The common practice is to test predicate before pthread_cond_wait.
+    I don't do that here because the predicate is practically always false
+    before wait - is_shutdown's been just set, and the lock's still not
+    released - the only case when the predicate is false is when no other
+    threads exist.
+  */
   while (pthread_cond_timedwait(&COND_thread_repository_is_empty,
                                 &LOCK_thread_repository,
                                 &shutdown_time) != ETIMEDOUT &&
@@ -167,7 +174,7 @@
     ;
   /*
     If previous signals did not reach some threads, they must be sleeping 
-    in pthread_cond_wait or a blocking syscall. Wake them up: 
+    in pthread_cond_wait or in a blocking syscall. Wake them up: 
     every thread shall check signal variables after each syscall/cond_wait,
     so this time everybody should be informed (presumably each worker can
     get CPU during shutdown_time.)
Thread
bk commit into 5.0 tree (1.1567)konstantin21 Aug