summaryrefslogtreecommitdiff
path: root/server-tools
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2005-11-05 01:32:55 +0200
committerunknown <monty@mysql.com>2005-11-05 01:32:55 +0200
commit2361720c981fc2eb27bc97c1ea7e043b634ffae1 (patch)
tree4a7b533b6da471261f5c13c46e4e9f256ec63a0c /server-tools
parenta3db4abe8b5ecad27adaff3baa78a913d0b84f10 (diff)
parentd4a7867a9ee0a44c8c943c75b5eb15e450ac61a7 (diff)
downloadmariadb-git-2361720c981fc2eb27bc97c1ea7e043b634ffae1.tar.gz
Merge mysql.com:/home/my/mysql-5.0
into mysql.com:/home/my/mysql-5.1 BUILD/FINISH.sh: Auto merged BitKeeper/deleted/.del-makefilewin.i~5c8479dcb8a455b2: Auto merged BitKeeper/deleted/.del-makefilewin~13888739357b3025: Auto merged BitKeeper/deleted/.del-makefilewin~14f24a4a173e2fcd: Auto merged BitKeeper/deleted/.del-makefilewin~15e9e5c9e8fa870b: Auto merged BitKeeper/deleted/.del-makefilewin~1c53f31b88dd36e: Auto merged BitKeeper/deleted/.del-makefilewin~1dbc058d76ebf1db: Auto merged BitKeeper/deleted/.del-makefilewin~2e0407fe123f8365: Auto merged BitKeeper/deleted/.del-makefilewin~2fc379bd4065c995: Auto merged BitKeeper/deleted/.del-makefilewin~389ee2dcf79afb79: Auto merged BitKeeper/deleted/.del-makefilewin~4d139e182457e553: Auto merged BitKeeper/deleted/.del-makefilewin~5104767c73775697: Auto merged BitKeeper/deleted/.del-makefilewin~608ed49dcd88e0f7: Auto merged BitKeeper/deleted/.del-makefilewin~63acd666293282a: Auto merged BitKeeper/deleted/.del-makefilewin~6ba64863bce3d0b8: Auto merged BitKeeper/deleted/.del-makefilewin~72a64128bacce71b: Auto merged BitKeeper/deleted/.del-makefilewin~78000390c783b1c5: Auto merged BitKeeper/deleted/.del-makefilewin~7a9d7d5a42bbfaf5: Auto merged Makefile.am: Auto merged BitKeeper/deleted/.del-makefilewin~a40ea12eebdd6ef0: Auto merged BitKeeper/deleted/.del-makefilewin~aeea7c82f21f7cf5: Auto merged BitKeeper/deleted/.del-makefilewin~b643e38d8da389ac: Auto merged BitKeeper/deleted/.del-makefilewin~c7b621c745e5de95: Auto merged BitKeeper/deleted/.del-makefilewin~c8273a47b90f52bb: Auto merged BitKeeper/deleted/.del-makefilewin~d1a9d1f7d33fcb73: Auto merged BitKeeper/deleted/.del-makefilewin~d37b6b303348c871: Auto merged BitKeeper/deleted/.del-makefilewin~d90f35fdc3f2ee5f: Auto merged BitKeeper/deleted/.del-makefilewin~dc4b8ad5ea53bd: Auto merged BitKeeper/deleted/.del-makefilewin~dea10ec1c94f7be: Auto merged BitKeeper/deleted/.del-makefilewin~ef3a208fa0e9b0db: Auto merged BitKeeper/deleted/.del-makefilewin~f1e3b890aa1c9ea3: Auto merged BitKeeper/deleted/.del-makefilewin~f4b7b99a887b7de: Auto merged BitKeeper/deleted/.del-makefilewin~fdda94ad32fa9e34: Auto merged BitKeeper/deleted/.del-my_cnf~977f69858affc57b: Auto merged BitKeeper/etc/config: Auto merged VC++Files/libmysqld/libmysqld.dsp: Auto merged VC++Files/sql/mysqld.dsp: Auto merged client/mysqltest.c: Auto merged include/Makefile.am: Auto merged include/base64.h: Auto merged include/my_base.h: Auto merged include/mysql_com.h: Auto merged libmysqld/Makefile.am: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/ndb_basic.result: Auto merged mysql-test/r/ndb_condition_pushdown.result: Auto merged mysql-test/t/alter_table.test: Auto merged mysql-test/t/disabled.def: Auto merged mysql-test/t/query_cache.test: Auto merged mysys/Makefile.am: Auto merged mysys/base64.c: Auto merged scripts/make_win_src_distribution.sh: Auto merged scripts/mysql_create_system_tables.sh: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged sql/Makefile.am: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_berkeley.h: Auto merged sql/ha_federated.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/handler.h: Auto merged sql/item.cc: Auto merged sql/item_subselect.cc: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysqld.cc: Auto merged sql/opt_range.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/slave.cc: Auto merged sql/slave.h: Auto merged sql/sp.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_delete.cc: Auto merged sql/sql_help.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_load.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.h: Auto merged storage/heap/_check.c: Auto merged storage/heap/hp_create.c: Auto merged storage/innobase/include/Makefile.am: Auto merged storage/innobase/include/rem0rec.h: Auto merged storage/innobase/include/rem0rec.ic: Auto merged storage/innobase/row/row0ins.c: Auto merged storage/innobase/row/row0upd.c: Auto merged storage/myisam/mi_check.c: Auto merged storage/myisam/mi_delete.c: Auto merged storage/myisam/mi_rkey.c: Auto merged storage/myisam/mi_rnext_same.c: Auto merged storage/myisam/mi_search.c: Auto merged storage/myisam/mi_write.c: Auto merged storage/myisam/myisamchk.c: Auto merged storage/myisam/myisamdef.h: Auto merged storage/myisam/sort.c: Auto merged storage/myisammrg/myrg_queue.c: Auto merged storage/ndb/config/type_util.mk.am: Auto merged storage/ndb/include/kernel/signaldata/DumpStateOrd.hpp: Auto merged storage/ndb/include/mgmapi/mgmapi_config_parameters.h: Auto merged storage/ndb/include/mgmapi/ndbd_exit_codes.h: Auto merged storage/ndb/include/transporter/TransporterCallback.hpp: Auto merged storage/ndb/src/common/mgmcommon/IPCConfig.cpp: Auto merged storage/ndb/src/common/transporter/SHM_Transporter.cpp: Auto merged storage/ndb/src/common/transporter/SHM_Transporter.hpp: Auto merged storage/ndb/src/common/transporter/SHM_Transporter.unix.cpp: Auto merged storage/ndb/src/common/transporter/SHM_Transporter.win32.cpp: Auto merged storage/ndb/src/common/transporter/Transporter.hpp: Auto merged storage/ndb/src/common/transporter/TransporterRegistry.cpp: Auto merged storage/ndb/src/common/util/Makefile.am: Auto merged storage/ndb/src/common/util/Parser.cpp: Auto merged storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Auto merged storage/ndb/src/kernel/blocks/ndbcntr/NdbcntrMain.cpp: Auto merged storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Auto merged storage/ndb/src/kernel/error/ndbd_exit_codes.c: Auto merged storage/ndb/src/kernel/vm/FastScheduler.cpp: Auto merged storage/ndb/src/kernel/vm/TransporterCallback.cpp: Auto merged storage/ndb/src/kernel/vm/VMSignal.hpp: Auto merged storage/ndb/src/mgmapi/mgmapi.cpp: Auto merged storage/ndb/src/mgmsrv/ConfigInfo.cpp: Auto merged storage/ndb/src/mgmsrv/InitConfigFileParser.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.cpp: Auto merged storage/ndb/src/mgmsrv/MgmtSrvr.hpp: Auto merged storage/ndb/src/mgmsrv/Services.cpp: Auto merged storage/ndb/src/ndbapi/TransporterFacade.cpp: Auto merged storage/ndb/test/ndbapi/testBackup.cpp: Auto merged storage/ndb/test/ndbapi/testOperations.cpp: Auto merged storage/ndb/test/src/HugoCalculator.cpp: Auto merged storage/ndb/tools/ndb_condig.cpp: Auto merged strings/ctype-big5.c: Auto merged strings/ctype-ucs2.c: Auto merged support-files/mysql.spec.sh: Auto merged BUILD/SETUP.sh: manual merge configure.in: manual merge mysql-test/r/alter_table.result: manual merge sql/handler.cc: manual merge sql/mysql_priv.h: manual merge sql/records.cc: manual merge sql/share/errmsg.txt: manual merge sql/sql_table.cc: manual merge Fix labels sql/sql_update.cc: manual merge sql/table.cc: manual merge sql/unireg.cc: manual merge storage/ndb/config/type_ndbapi.mk.am: manual merge
Diffstat (limited to 'server-tools')
-rw-r--r--server-tools/instance-manager/Makefile.am4
-rw-r--r--server-tools/instance-manager/command.h4
-rw-r--r--server-tools/instance-manager/instance.cc21
-rw-r--r--server-tools/instance-manager/instance_options.cc11
-rw-r--r--server-tools/instance-manager/listener.cc15
-rw-r--r--server-tools/instance-manager/listener.h6
-rw-r--r--server-tools/instance-manager/manager.cc22
-rw-r--r--server-tools/instance-manager/mysql_connection.h7
-rw-r--r--server-tools/instance-manager/options.h8
-rw-r--r--server-tools/instance-manager/parse_output.cc25
-rw-r--r--server-tools/instance-manager/priv.cc36
-rw-r--r--server-tools/instance-manager/priv.h6
-rw-r--r--server-tools/instance-manager/thread_registry.cc23
-rw-r--r--server-tools/instance-manager/thread_registry.h16
-rw-r--r--server-tools/instance-manager/user_map.h7
15 files changed, 152 insertions, 59 deletions
diff --git a/server-tools/instance-manager/Makefile.am b/server-tools/instance-manager/Makefile.am
index b872adca09d..4fa2a0da405 100644
--- a/server-tools/instance-manager/Makefile.am
+++ b/server-tools/instance-manager/Makefile.am
@@ -15,7 +15,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
INCLUDES= @ZLIB_INCLUDES@ -I$(top_srcdir)/include \
- $(openssl_includes) -I$(top_builddir)/include
+ @openssl_includes@ @yassl_includes@ -I$(top_builddir)/include
DEFS= -DMYSQL_INSTANCE_MANAGER -DMYSQL_SERVER
@@ -85,7 +85,7 @@ mysqlmanager_LDADD= liboptions.a \
$(top_builddir)/mysys/libmysys.a \
$(top_builddir)/strings/libmystrings.a \
$(top_builddir)/dbug/libdbug.a \
- @openssl_libs@ @ZLIB_LIBS@
+ @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@
tags:
diff --git a/server-tools/instance-manager/command.h b/server-tools/instance-manager/command.h
index 82ded800e65..b84cc6a8e9e 100644
--- a/server-tools/instance-manager/command.h
+++ b/server-tools/instance-manager/command.h
@@ -16,12 +16,12 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
+
#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
#pragma interface
#endif
-#include <my_global.h>
-
/* Class responsible for allocation of im commands. */
class Instance_map;
diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc
index ff3387334b6..3d54d000d5f 100644
--- a/server-tools/instance-manager/instance.cc
+++ b/server-tools/instance-manager/instance.cc
@@ -138,15 +138,25 @@ static int wait_process(My_process_info *pi)
static int start_process(Instance_options *instance_options,
My_process_info *pi)
{
+#ifndef __QNX__
*pi= fork();
+#else
+ /*
+ On QNX one cannot use fork() in multithreaded environment and we
+ should use spawn() or one of it's siblings instead.
+ Here we use spawnv(), which is a combination of fork() and execv()
+ in one call. It returns the pid of newly created process (>0) or -1
+ */
+ *pi= spawnv(P_NOWAIT, instance_options->mysqld_path, instance_options->argv);
+#endif
switch (*pi) {
- case 0:
+ case 0: /* never happens on QNX */
execv(instance_options->mysqld_path, instance_options->argv);
/* exec never returns */
exit(1);
- case 1:
- log_info("cannot fork() to start instance %s",
+ case -1:
+ log_info("cannot create a new process to start instance %s",
instance_options->instance_name);
return 1;
}
@@ -170,7 +180,8 @@ static int start_process(Instance_options *instance_options,
char *cmdline= new char[cmdlen];
if (cmdline == NULL)
return 1;
-
+
+ cmdline[0]= 0;
for (int i= 0; instance_options->argv[i] != 0; i++)
{
strcat(cmdline, "\"");
@@ -469,7 +480,7 @@ int Instance::stop()
status= pthread_cond_timedwait(&COND_instance_stopped,
&LOCK_instance,
&timeout);
- if (status == ETIMEDOUT)
+ if (status == ETIMEDOUT || status == ETIME)
break;
}
diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc
index 25609f489af..83f13b34aa2 100644
--- a/server-tools/instance-manager/instance_options.cc
+++ b/server-tools/instance-manager/instance_options.cc
@@ -47,14 +47,12 @@ static inline int create_mysqld_command(Buffer *buf,
if (buf->get_size()) /* malloc succeeded */
{
#ifdef __WIN__
- buf->append(position, "\"", 1);
- position++;
+ buf->append(position++, "\"", 1);
#endif
buf->append(position, mysqld_path_str, mysqld_path_len);
position+= mysqld_path_len;
#ifdef __WIN__
- buf->append(position, "\"", 1);
- position++;
+ buf->append(position++, "\"", 1);
#endif
/* here the '\0' character is copied from the option string */
buf->append(position, option, option_len);
@@ -336,10 +334,15 @@ int Instance_options::complete_initialization(const char *default_path,
uint instance_type)
{
const char *tmp;
+ char *end;
if (!mysqld_path && !(mysqld_path= strdup_root(&alloc, default_path)))
goto err;
+ // it's safe to cast this to char* since this is a buffer we are allocating
+ end= convert_dirname((char*)mysqld_path, mysqld_path, NullS);
+ end[-1]= 0;
+
mysqld_path_len= strlen(mysqld_path);
if (mysqld_port)
diff --git a/server-tools/instance-manager/listener.cc b/server-tools/instance-manager/listener.cc
index 08c28dc9f7d..67d798a1700 100644
--- a/server-tools/instance-manager/listener.cc
+++ b/server-tools/instance-manager/listener.cc
@@ -122,11 +122,15 @@ void Listener_thread::run()
n++;
timeval tv;
- tv.tv_sec= 0;
- tv.tv_usec= 100000;
while (!thread_registry.is_shutdown())
{
fd_set read_fds_arg= read_fds;
+ /*
+ We should reintialize timer as on linux it is modified
+ to reflect amount of time not slept.
+ */
+ tv.tv_sec= 0;
+ tv.tv_usec= 100000;
/*
When using valgrind 2.0 this syscall doesn't get kicked off by a
@@ -358,12 +362,13 @@ void Listener_thread::handle_new_mysql_connection(Vio *vio)
pthread_attr_t mysql_thd_attr;
pthread_attr_init(&mysql_thd_attr);
pthread_attr_setdetachstate(&mysql_thd_attr, PTHREAD_CREATE_DETACHED);
- if (pthread_create(&mysql_thd_id, &mysql_thd_attr, mysql_connection,
- mysql_thread_args))
+ if (set_stacksize_n_create_thread(&mysql_thd_id, &mysql_thd_attr,
+ mysql_connection, mysql_thread_args))
{
delete mysql_thread_args;
vio_delete(vio);
- log_error("handle_one_mysql_connection(): pthread_create(mysql) failed");
+ log_error("handle_one_mysql_connection():"
+ "set_stacksize_n_create_thread(mysql) failed");
}
pthread_attr_destroy(&mysql_thd_attr);
}
diff --git a/server-tools/instance-manager/listener.h b/server-tools/instance-manager/listener.h
index e0ab5b8ef2b..28ccbf91731 100644
--- a/server-tools/instance-manager/listener.h
+++ b/server-tools/instance-manager/listener.h
@@ -16,13 +16,13 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
+#include <my_pthread.h>
+
#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
#pragma interface
#endif
-#include <my_global.h>
-#include <my_pthread.h>
-
pthread_handler_t listener(void *arg);
diff --git a/server-tools/instance-manager/manager.cc b/server-tools/instance-manager/manager.cc
index a42a25eadf3..3ecd5fbc0d0 100644
--- a/server-tools/instance-manager/manager.cc
+++ b/server-tools/instance-manager/manager.cc
@@ -162,12 +162,12 @@ void manager(const Options &options)
pthread_attr_init(&listener_thd_attr);
pthread_attr_setdetachstate(&listener_thd_attr, PTHREAD_CREATE_DETACHED);
- rc= pthread_create(&listener_thd_id, &listener_thd_attr, listener,
- &listener_args);
+ rc= set_stacksize_n_create_thread(&listener_thd_id, &listener_thd_attr,
+ listener, &listener_args);
pthread_attr_destroy(&listener_thd_attr);
if (rc)
{
- log_error("manager(): pthread_create(listener) failed");
+ log_error("manager(): set_stacksize_n_create_thread(listener) failed");
goto err;
}
@@ -187,12 +187,12 @@ void manager(const Options &options)
pthread_attr_init(&guardian_thd_attr);
pthread_attr_setdetachstate(&guardian_thd_attr, PTHREAD_CREATE_DETACHED);
- rc= pthread_create(&guardian_thd_id, &guardian_thd_attr, guardian,
- &guardian_thread);
+ rc= set_stacksize_n_create_thread(&guardian_thd_id, &guardian_thd_attr,
+ guardian, &guardian_thread);
pthread_attr_destroy(&guardian_thd_attr);
if (rc)
{
- log_error("manager(): pthread_create(guardian) failed");
+ log_error("manager(): set_stacksize_n_create_thread(guardian) failed");
goto err;
}
@@ -231,6 +231,16 @@ void manager(const Options &options)
}
#ifndef __WIN__
+/*
+ On some Darwin kernels SIGHUP is delivered along with most
+ signals. This is why we skip it's processing on these
+ platforms. For more details and test program see
+ Bug #14164 IM tests fail on MacOS X (powermacg5)
+*/
+#ifdef IGNORE_SIGHUP_SIGQUIT
+ if ( SIGHUP == signo )
+ continue;
+#endif
if (THR_SERVER_ALARM == signo)
process_alarm(signo);
else
diff --git a/server-tools/instance-manager/mysql_connection.h b/server-tools/instance-manager/mysql_connection.h
index 492937b2198..3496cc05815 100644
--- a/server-tools/instance-manager/mysql_connection.h
+++ b/server-tools/instance-manager/mysql_connection.h
@@ -16,13 +16,12 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
-#pragma interface
-#endif
-
#include <my_global.h>
#include <my_pthread.h>
+#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
+#pragma interface
+#endif
pthread_handler_t mysql_connection(void *arg);
diff --git a/server-tools/instance-manager/options.h b/server-tools/instance-manager/options.h
index 3a60de2bb39..6d719c69629 100644
--- a/server-tools/instance-manager/options.h
+++ b/server-tools/instance-manager/options.h
@@ -16,16 +16,16 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
-#pragma interface
-#endif
-
/*
Options - all possible options for the instance manager grouped in one
struct.
*/
#include <my_global.h>
+#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
+#pragma interface
+#endif
+
struct Options
{
#ifdef __WIN__
diff --git a/server-tools/instance-manager/parse_output.cc b/server-tools/instance-manager/parse_output.cc
index b5af3cb83a7..ebc45c1f7d4 100644
--- a/server-tools/instance-manager/parse_output.cc
+++ b/server-tools/instance-manager/parse_output.cc
@@ -24,6 +24,20 @@
#include "portability.h"
+void trim_space(const char **text, uint *word_len)
+{
+ const char *start= *text;
+ while (*start != 0 && *start == ' ')
+ start++;
+ *text= start;
+
+ int len= strlen(start);
+ const char *end= start + len - 1;
+ while (end > start && my_isspace(&my_charset_latin1, *end))
+ end--;
+ *word_len= (end - start)+1;
+}
+
/*
Parse output of the given command
@@ -82,20 +96,17 @@ int parse_output_and_get_value(const char *command, const char *word,
linebuf[sizeof(linebuf) - 1]= '\0'; /* safety */
/*
- Get the word, which might contain non-alphanumeric characters. (Usually
- these are '/', '-' and '.' in the path expressions and filenames)
+ Compare the start of our line with the word(s) we are looking for.
*/
- get_word((const char **) &linep, &found_word_len, NONSPACE);
if (!strncmp(word, linep, wordlen))
{
/*
- If we have found the word, return the next one (this is usually
- an option value) or the whole line (if flag)
+ If we have found our word(s), then move linep past the word(s)
*/
- linep+= found_word_len; /* swallow the previous one */
+ linep+= wordlen;
if (flag & GET_VALUE)
{
- get_word((const char **) &linep, &found_word_len, NONSPACE);
+ trim_space((const char**) &linep, &found_word_len);
if (input_buffer_len <= found_word_len)
goto err;
strmake(result, linep, found_word_len);
diff --git a/server-tools/instance-manager/priv.cc b/server-tools/instance-manager/priv.cc
index 02a788ec469..a5040aa2e83 100644
--- a/server-tools/instance-manager/priv.cc
+++ b/server-tools/instance-manager/priv.cc
@@ -18,6 +18,17 @@
#include "priv.h"
#include "portability.h"
+#if defined(__ia64__) || defined(__ia64)
+/*
+ We can live with 32K, but reserve 64K. Just to be safe.
+ On ia64 we need to reserve double of the size.
+*/
+#define IM_THREAD_STACK_SIZE (128*1024L)
+#else
+#define IM_THREAD_STACK_SIZE (64*1024)
+#endif
+
+
/* the pid of the manager process (of the signal thread on the LinuxThreads) */
pid_t manager_pid;
@@ -52,3 +63,28 @@ unsigned int test_flags= 0;
unsigned long bytes_sent = 0L, bytes_received = 0L;
unsigned long mysqld_net_retry_count = 10L;
unsigned long open_files_limit;
+
+/*
+ Change the stack size and start a thread. Return an error if either
+ pthread_attr_setstacksize or pthread_create fails.
+ Arguments are the same as for pthread_create().
+*/
+
+int set_stacksize_n_create_thread(pthread_t *thread, pthread_attr_t *attr,
+ void *(*start_routine)(void *), void *arg)
+{
+ int rc= 0;
+
+#ifndef __WIN__
+ /*
+ Set stack size to be safe on the platforms with too small
+ default thread stack.
+ */
+ rc= pthread_attr_setstacksize(attr,
+ (size_t) (PTHREAD_STACK_MIN +
+ IM_THREAD_STACK_SIZE));
+#endif
+ if (!rc)
+ rc= pthread_create(thread, attr, start_routine, arg);
+ return rc;
+}
diff --git a/server-tools/instance-manager/priv.h b/server-tools/instance-manager/priv.h
index ce9d54293c7..4739bca68eb 100644
--- a/server-tools/instance-manager/priv.h
+++ b/server-tools/instance-manager/priv.h
@@ -22,7 +22,7 @@
#else
#include <unistd.h>
#endif
-
+#include "my_pthread.h"
/* the pid of the manager process (of the signal thread on the LinuxThreads) */
extern pid_t manager_pid;
@@ -80,4 +80,8 @@ extern unsigned long bytes_sent, bytes_received;
extern unsigned long mysqld_net_retry_count;
extern unsigned long open_files_limit;
+
+int set_stacksize_n_create_thread(pthread_t *thread, pthread_attr_t *attr,
+ void *(*start_routine)(void *), void *arg);
+
#endif // INCLUDES_MYSQL_INSTANCE_MANAGER_PRIV_H
diff --git a/server-tools/instance-manager/thread_registry.cc b/server-tools/instance-manager/thread_registry.cc
index fe665f410e5..0091d713a91 100644
--- a/server-tools/instance-manager/thread_registry.cc
+++ b/server-tools/instance-manager/thread_registry.cc
@@ -1,4 +1,4 @@
-/* cOPYRIght (C) 2003 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
@@ -38,6 +38,14 @@ static void handle_signal(int __attribute__((unused)) sig_no)
#endif
/*
+ Thread_info initializer methods
+*/
+
+Thread_info::Thread_info() {}
+Thread_info::Thread_info(pthread_t thread_id_arg) :
+ thread_id(thread_id_arg) {}
+
+/*
TODO: think about moving signal information (now it's shutdown_in_progress)
to Thread_info. It will reduce contention and allow signal deliverence to
a particular thread, not to the whole worker crew
@@ -145,6 +153,7 @@ int Thread_registry::cond_timedwait(Thread_info *info, pthread_cond_t *cond,
pthread_mutex_t *mutex,
struct timespec *wait_time)
{
+ int rc;
pthread_mutex_lock(&LOCK_thread_registry);
if (shutdown_in_progress)
{
@@ -154,7 +163,8 @@ int Thread_registry::cond_timedwait(Thread_info *info, pthread_cond_t *cond,
info->current_cond= cond;
pthread_mutex_unlock(&LOCK_thread_registry);
/* sic: race condition here, cond can be signaled in deliver_shutdown */
- int rc= pthread_cond_timedwait(cond, mutex, wait_time);
+ if ((rc= pthread_cond_timedwait(cond, mutex, wait_time)) == ETIME)
+ rc= ETIMEDOUT; // For easier usage
pthread_mutex_lock(&LOCK_thread_registry);
info->current_cond= 0;
pthread_mutex_unlock(&LOCK_thread_registry);
@@ -172,6 +182,7 @@ void Thread_registry::deliver_shutdown()
{
Thread_info *info;
struct timespec shutdown_time;
+ int error;
set_timespec(shutdown_time, 1);
pthread_mutex_lock(&LOCK_thread_registry);
@@ -204,11 +215,13 @@ void Thread_registry::deliver_shutdown()
released - the only case when the predicate is false is when no other
threads exist.
*/
- while (pthread_cond_timedwait(&COND_thread_registry_is_empty,
- &LOCK_thread_registry,
- &shutdown_time) != ETIMEDOUT &&
+ while (((error= pthread_cond_timedwait(&COND_thread_registry_is_empty,
+ &LOCK_thread_registry,
+ &shutdown_time)) != ETIMEDOUT &&
+ error != ETIME) &&
head.next != &head)
;
+
/*
If previous signals did not reach some threads, they must be sleeping
in pthread_cond_wait or in a blocking syscall. Wake them up:
diff --git a/server-tools/instance-manager/thread_registry.h b/server-tools/instance-manager/thread_registry.h
index a1075e719d6..6dc320a8533 100644
--- a/server-tools/instance-manager/thread_registry.h
+++ b/server-tools/instance-manager/thread_registry.h
@@ -50,13 +50,12 @@
in manner, similar to ``quit'' signals.
*/
-#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
-#pragma interface
-#endif
-
#include <my_global.h>
#include <my_pthread.h>
+#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
+#pragma interface
+#endif
/*
Thread_info - repository entry for each worker thread
@@ -67,13 +66,14 @@
class Thread_info
{
+public:
+ Thread_info();
+ Thread_info(pthread_t thread_id_arg);
+ friend class Thread_registry;
+private:
pthread_cond_t *current_cond;
Thread_info *prev, *next;
pthread_t thread_id;
- Thread_info() {}
- friend class Thread_registry;
-public:
- Thread_info(pthread_t thread_id_arg) : thread_id(thread_id_arg) {}
};
diff --git a/server-tools/instance-manager/user_map.h b/server-tools/instance-manager/user_map.h
index a57174a37c3..4134017dd9b 100644
--- a/server-tools/instance-manager/user_map.h
+++ b/server-tools/instance-manager/user_map.h
@@ -16,15 +16,16 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
-#pragma interface
-#endif
#include <my_global.h>
#include <my_sys.h>
#include <hash.h>
+#if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
+#pragma interface
+#endif
+
/*
User_map -- all users and passwords
*/