summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-12-17 03:02:58 +0200
committerunknown <monty@hundin.mysql.fi>2001-12-17 03:02:58 +0200
commit8f05035c27d876380965b53b4f1b2ab046825c6f (patch)
tree941257314e6e021bd649a4b42156be700895e6a0
parent565e5cc71de483e9bdf5ff6897c861190125db3e (diff)
downloadmariadb-git-8f05035c27d876380965b53b4f1b2ab046825c6f.tar.gz
Lots of portability fixes.
Fixed shutdown on HPUX. Fixed bug in query cache. Docs/manual.texi: Changelog configure.in: Fixes for HPUX include/m_string.h: Fixes for Purify include/my_pthread.h: Fixes for HPUX include/raid.h: Portability fix. innobase/include/univ.i: Portability fix. mysql-test/mysql-test-run.sh: Added --manual-gdb mysql-test/r/rpl_log.result: Portability fix mysql-test/t/rpl_log.test: Portability fix mysys/my_pthread.c: Portability fix (HPUX) mysys/raid.cc: Portability fix mysys/thr_mutex.c: Portability fix scripts/mysql_install_db.sh: Clean up install message sql-bench/test-alter-table.sh: Fix testsuite sql/ha_innobase.cc: Fixed stack overwrite. sql/log_event.cc: Fixed purify warning sql/mysqld.cc: Added patch from FreeBSD port. Fixed shutdown on HPUX. sql/slave.cc: Cleanup sql/sql_cache.cc: Binary search in 'step' searching Check maximal block in bin Limit of comparasions number in list of memory blocks. Fixed bug in pack() sql/sql_cache.h: Binary search in 'step' searching Check maximal block in bin Limit of comparasions number in list of memory blocks. Fixed bug in pack() sql/sql_parse.cc: Optimize tools/mysqlmanager.c: Portability fix
-rw-r--r--Docs/manual.texi2
-rw-r--r--configure.in8
-rw-r--r--include/m_string.h2
-rw-r--r--include/my_pthread.h5
-rw-r--r--include/raid.h9
-rw-r--r--innobase/include/univ.i1
-rw-r--r--mysql-test/mysql-test-run.sh35
-rw-r--r--mysql-test/r/rpl_log.result13
-rw-r--r--mysql-test/t/rpl_log.test5
-rw-r--r--mysys/my_pthread.c22
-rw-r--r--mysys/raid.cc8
-rw-r--r--mysys/thr_mutex.c10
-rw-r--r--scripts/mysql_install_db.sh4
-rw-r--r--sql-bench/test-alter-table.sh4
-rw-r--r--sql/ha_innobase.cc6
-rw-r--r--sql/log_event.cc2
-rw-r--r--sql/mysqld.cc74
-rw-r--r--sql/slave.cc8
-rw-r--r--sql/sql_cache.cc59
-rw-r--r--sql/sql_cache.h4
-rw-r--r--sql/sql_parse.cc5
-rw-r--r--tools/mysqlmanager.c9
22 files changed, 189 insertions, 106 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi
index 4d059bd496a..81932c6afd9 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -47795,6 +47795,8 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet
@item
+Fixed shutdown problem on HPUX.
+@item
Added functions @code{des_encrypt()} and @code{des_decrypt()}.
@item
Added statement FLUSH DES_KEY_FILE.
diff --git a/configure.in b/configure.in
index e4dc902f6e4..084ce2db6b8 100644
--- a/configure.in
+++ b/configure.in
@@ -819,8 +819,8 @@ case $SYSTEM_TYPE in
;;
*hpux10.20*)
echo "Enabling snprintf workaround for hpux 10.20"
- CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF -DSIGNALS_DONT_BREAK_READ"
- CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG -DSIGNALS_DONT_BREAK_READ"
+ CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX"
+ CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX"
if test "$with_named_thread" = "no"
then
echo "Using --with-named-thread=-lpthread"
@@ -829,8 +829,8 @@ case $SYSTEM_TYPE in
;;
*hpux11.*)
echo "Enabling pread/pwrite workaround for hpux 11"
- CFLAGS="$CFLAGS -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK"
- CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -D_INCLUDE_LONGLONG -DNO_FCNTL_NONBLOCK"
+ CFLAGS="$CFLAGS -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS"
+ CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -D_INCLUDE_LONGLONG -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS"
if test "$with_named_thread" = "no"
then
echo "Using --with-named-thread=-lpthread"
diff --git a/include/m_string.h b/include/m_string.h
index 6e906bef023..17b5a07a10b 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -131,11 +131,11 @@ extern void bzero(gptr dst,uint len);
#if !defined(bcmp) && !defined(HAVE_BCMP)
extern int bcmp(const char *s1,const char *s2,uint len);
+#endif
#ifdef HAVE_purify
extern int my_bcmp(const char *s1,const char *s2,uint len);
#define bcmp(A,B,C) my_bcmp((A),(B),(C))
#endif
-#endif
#ifndef bmove512
extern void bmove512(gptr dst,const gptr src,uint len);
diff --git a/include/my_pthread.h b/include/my_pthread.h
index df42ebeadd0..bee5f5d92f4 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -446,6 +446,10 @@ struct hostent *my_gethostbyname_r(const char *name,
#endif /* defined(__WIN__) */
+#if defined(HPUX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS)
+#define pthread_cond_timedwait(a,b,c) my_pthread_cond_timedwait((a),(b),(c))
+#endif
+
/* safe_mutex adds checking to mutex for easier debugging */
typedef struct st_safe_mutex_t
@@ -476,6 +480,7 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
#undef pthread_mutex_t
#undef pthread_cond_wait
#undef pthread_cond_timedwait
+#undef pthread_mutex_trylock
#define pthread_mutex_init(A,B) safe_mutex_init((A),(B))
#define pthread_mutex_lock(A) safe_mutex_lock((A),__FILE__,__LINE__)
#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__)
diff --git a/include/raid.h b/include/raid.h
index e2e2cf5a567..7655fbe09f7 100644
--- a/include/raid.h
+++ b/include/raid.h
@@ -23,14 +23,7 @@
#define RAID_DEFAULT_CHUNKSIZE 256*1024 /* 256kB */
extern const char *raid_type_string[];
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-const char *my_raid_type(int raid_type);
-#ifdef __cplusplus
-}
-#endif
+#define my_raid_type(raid_type) raid_type_string[(int)(raid_type)]
#if defined(USE_RAID) && !defined(DONT_USE_RAID)
diff --git a/innobase/include/univ.i b/innobase/include/univ.i
index 584757529cf..8870d80f611 100644
--- a/innobase/include/univ.i
+++ b/innobase/include/univ.i
@@ -30,6 +30,7 @@ be defined:
/* Most C compilers other than gcc do not know 'extern inline' */
#if !defined(__GNUC__) && !defined(__WIN__)
+#undef UNIV_MUST_NOT_INLINE
#define UNIV_MUST_NOT_INLINE
#endif
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index f2f0c2a4234..932b063cbcf 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -170,6 +170,7 @@ EXTRA_MYSQL_TEST_OPT=""
USE_RUNNING_SERVER=1
DO_GCOV=""
DO_GDB=""
+MANUAL_GDB=""
DO_DDD=""
DO_CLIENT_GDB=""
SLEEP_TIME_FOR_DELETE=10
@@ -272,6 +273,11 @@ while test $# -gt 0; do
fi
DO_CLIENT_GDB=1
;;
+ --manual-gdb )
+ DO_GDB=1
+ MANUAL_GDB=1
+ USE_RUNNING_SERVER=""
+ ;;
--ddd )
if [ x$BINARY_DIST = x1 ] ; then
$ECHO "Note: you will get more meaningful output on a source distribution compiled with debugging option when running tests with --ddd option"
@@ -743,8 +749,15 @@ start_master()
"gdb -x $GDB_MASTER_INIT" $MYSQLD
elif [ x$DO_GDB = x1 ]
then
- ( echo set args $master_args;
- if [ $USE_MANAGER = 0 ] ; then
+ if [ x$MANUAL_GDB = x1 ]
+ then
+ $ECHO "set args $master_args" > $GDB_MASTER_INIT
+ $ECHO "To start gdb for the master , type in another window:"
+ $ECHO "cd $CWD ; gdb -x $GDB_MASTER_INIT $MYSQLD"
+ wait_for_master=1500
+ else
+ ( $ECHO set args $master_args;
+ if [ $USE_MANAGER = 0 ] ; then
cat <<EOF
b mysql_parse
commands 1
@@ -752,9 +765,10 @@ disa 1
end
r
EOF
- fi ) > $GDB_MASTER_INIT
- manager_launch master $XTERM -display $DISPLAY \
- -title "Master" -e gdb -x $GDB_MASTER_INIT $MYSQLD
+ fi ) > $GDB_MASTER_INIT
+ manager_launch master $XTERM -display $DISPLAY \
+ -title "Master" -e gdb -x $GDB_MASTER_INIT $MYSQLD
+ fi
else
manager_launch master $MYSQLD $master_args
fi
@@ -845,8 +859,15 @@ start_slave()
elif [ x$DO_GDB = x1 ]
then
$ECHO "set args $slave_args" > $GDB_SLAVE_INIT
- manager_launch $slave_ident $XTERM -display $DISPLAY -title "Slave" -e \
- gdb -x $GDB_SLAVE_INIT $SLAVE_MYSQLD
+ if [ x$MANUAL_GDB = x1 ]
+ then
+ echo "To start gdb for the slave, type in another window:"
+ echo "cd $CWD ; gdb -x $GDB_SLAVE_INIT $MYSQLD"
+ wait_for_slave=1500
+ else
+ manager_launch $slave_ident $XTERM -display $DISPLAY -title "Slave" -e \
+ gdb -x $GDB_SLAVE_INIT $SLAVE_MYSQLD
+ fi
else
manager_launch $slave_ident $SLAVE_MYSQLD $slave_args
fi
diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result
index 7052b226d12..aabfb8252e6 100644
--- a/mysql-test/r/rpl_log.result
+++ b/mysql-test/r/rpl_log.result
@@ -67,19 +67,6 @@ Log_name
slave-bin.001
slave-bin.002
show binlog events in 'slave-bin.001' from 4;
-Log_name Pos Event_type Server_id Log_seq Info
-slave-bin.001 4 Start 2 1 Server ver: VERSION, Binlog ver: 2
-slave-bin.001 79 Slave 2 3 host=127.0.0.1,port=MASTER_PORT,log=master-bin.001,pos=4
-slave-bin.001 132 Query 1 2 use test; create table t1(n int not null auto_increment primary key)
-slave-bin.001 225 Intvar 1 3 INSERT_ID=1
-slave-bin.001 253 Query 1 4 use test; insert into t1 values (NULL)
-slave-bin.001 316 Query 1 5 use test; drop table t1
-slave-bin.001 364 Query 1 6 use test; create table t1 (word char(20) not null)
-slave-bin.001 439 Create_file 1 7 db=test;table=t1;file_id=1;block_len=81
-slave-bin.001 618 Exec_load 1 8 ;file_id=1
-slave-bin.001 641 Query 1 9 use test; drop table t1
-slave-bin.001 689 Rotate 1 4 slave-bin.002;pos=4; forced by master
-slave-bin.001 729 Stop 2 5
show binlog events in 'slave-bin.002' from 4;
Log_name Pos Event_type Server_id Log_seq Info
slave-bin.002 4 Slave 2 10 host=127.0.0.1,port=MASTER_PORT,log=master-bin.002,pos=4
diff --git a/mysql-test/t/rpl_log.test b/mysql-test/t/rpl_log.test
index 1732e88b9de..e7867f83263 100644
--- a/mysql-test/t/rpl_log.test
+++ b/mysql-test/t/rpl_log.test
@@ -35,8 +35,13 @@ slave start;
sync_with_master;
show master logs;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT $VERSION VERSION
+# We can't compare binlog from slave as the result differ between
+# machines based on where the LOAD DATA file is stored.
+disable_result_log;
+
show binlog events in 'slave-bin.001' from 4;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT $VERSION VERSION
+enable_result_log;
show binlog events in 'slave-bin.002' from 4;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c
index aeac95627dd..161e4faaff6 100644
--- a/mysys/my_pthread.c
+++ b/mysys/my_pthread.c
@@ -16,6 +16,7 @@
/* Functions to get threads more portable */
+#define DONT_REMAP_PTHREAD_FUNCTIONS
#include "mysys_priv.h"
#ifdef THREAD
#include <signal.h>
@@ -460,6 +461,27 @@ struct hostent *my_gethostbyname_r(const char *name,
#endif /* GLIBC2_STYLE_GETHOSTBYNAME_R */
#endif
+/*****************************************************************************
+ Patches for HPUX
+ We need these because the pthread_mutex.. code returns -1 on error,
+ instead of the error code.
+
+ Note that currently we only remap pthread_ functions used by MySQL.
+ If we are depending on the value for some other pthread_xxx functions,
+ this has to be added here.
+*****************************************************************************/
+
+int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
+ struct timespec *abstime)
+{
+ int error=pthread_cond_timedwait(cond, mutex, abstime);
+ if (error == -1) /* Safety if the lib is fixed */
+ error=errno;
+ if (error == EAGAIN) /* Correct errno to Posix */
+ error=ETIMEDOUT;
+ return error;
+}
+
/* Some help functions */
diff --git a/mysys/raid.cc b/mysys/raid.cc
index d48bf9db953..9809086a622 100644
--- a/mysys/raid.cc
+++ b/mysys/raid.cc
@@ -81,14 +81,6 @@
const char *raid_type_string[]={"none","striped"};
-
-extern "C" {
- const char *my_raid_type(int raid_type)
- {
- return raid_type_string[raid_type];
- }
-}
-
#if defined(USE_RAID) && !defined(MYSQL_CLIENT)
#define RAID_SEEK_DONE ~(off_t) 0
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index adb67ae95c5..5353e58ba2d 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -107,7 +107,7 @@ int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line)
error=pthread_mutex_unlock(&mp->mutex);
if (error)
{
- fprintf(stderr,"safe_mutex: Got error: %d when trying to unlock mutex at %s, line %d\n", error, file, line);
+ fprintf(stderr,"safe_mutex: Got error: %d (%d) when trying to unlock mutex at %s, line %d\n", error, errno, file, line);
fflush(stderr);
abort();
}
@@ -148,7 +148,7 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
pthread_mutex_lock(&mp->global);
if (error)
{
- fprintf(stderr,"safe_mutex: Got error: %d when doing a safe_mutex_wait at %s, line %d\n", error, file, line);
+ fprintf(stderr,"safe_mutex: Got error: %d (%d) when doing a safe_mutex_wait at %s, line %d\n", error, errno, file, line);
fflush(stderr);
abort();
}
@@ -186,15 +186,15 @@ int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
#ifdef EXTRA_DEBUG
if (error && (error != EINTR && error != ETIMEDOUT))
{
- fprintf(stderr,"safe_mutex: Got error: %d when doing a safe_mutex_timedwait at %s, line %d\n", error, file, line);
+ fprintf(stderr,"safe_mutex: Got error: %d (%d) when doing a safe_mutex_timedwait at %s, line %d\n", error, errno, file, line);
}
#endif
pthread_mutex_lock(&mp->global);
if (mp->count++)
{
fprintf(stderr,
- "safe_mutex: Count was %d in thread %lx when locking mutex at %s, line %d (error: %d)\n",
- mp->count-1, my_thread_id(), file, line, error);
+ "safe_mutex: Count was %d in thread %lx when locking mutex at %s, line %d (error: %d (%d))\n",
+ mp->count-1, my_thread_id(), file, line, error, error);
fflush(stderr);
abort();
}
diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
index 0da457582f1..bf577a6cc5c 100644
--- a/scripts/mysql_install_db.sh
+++ b/scripts/mysql_install_db.sh
@@ -321,8 +321,8 @@ then
fi
echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !"
echo "This is done with:"
- echo "$bindir/mysqladmin -u root -p password 'new-password'"
- echo "$bindir/mysqladmin -u root -h $hostname -p password 'new-password'"
+ echo "$bindir/mysqladmin -u root password 'new-password'"
+ echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'"
echo "See the manual for more instructions."
#
# Print message about upgrading unless we have created a new db table.
diff --git a/sql-bench/test-alter-table.sh b/sql-bench/test-alter-table.sh
index af0f630d938..cc6453188de 100644
--- a/sql-bench/test-alter-table.sh
+++ b/sql-bench/test-alter-table.sh
@@ -75,7 +75,7 @@ print "Insert data into the table\n";
$loop_time=new Benchmark;
-if ($opt_fast && defined($server->{transactions}))
+if ($opt_fast && $server->{transactions})
{
$dbh->{AutoCommit} = 0;
print "Transactions enabled\n" if ($opt_debug);
@@ -87,7 +87,7 @@ for ($i=0 ; $i < $opt_row_count ; $i++)
$dbh->do($query) or die $DBI::errstr;
}
-if ($opt_fast && defined($server->{transactions}))
+if ($opt_fast && $server->{transactions})
{
$dbh->commit;
$dbh->{AutoCommit} = 1;
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index fb22b2d079c..8dd2e49e093 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -536,7 +536,7 @@ innobase_init(void)
{
int err;
bool ret;
- char current_lib[2], *default_path;
+ char current_lib[3], *default_path;
DBUG_ENTER("innobase_init");
@@ -2044,7 +2044,7 @@ ha_innobase::change_active_index(
else
prebuilt->index = dict_table_get_first_index_noninline(prebuilt->table);
- assert(prebuilt->search_tuple);
+ assert(prebuilt->search_tuple != 0);
dtuple_set_n_fields(prebuilt->search_tuple, prebuilt->index->n_fields);
@@ -2762,7 +2762,7 @@ ha_innobase::create(
innobase_table = dict_table_get(norm_name, NULL);
- assert(innobase_table);
+ assert(innobase_table != 0);
/* Tell the InnoDB server that there might be work for
utility threads: */
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 3552a4264c9..ee975596f4b 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -140,7 +140,7 @@ static void cleanup_load_tmpdir()
for (i=0;i<(uint)dirp->number_off_files;i++)
{
file=dirp->dir_entry+i;
- if (!memcmp(file->name,"SQL_LOAD-",9))
+ if (!bcmp(file->name,"SQL_LOAD-",9))
my_delete(file->name,MYF(MY_WME));
}
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 1294f379d2b..60dd45bc1f2 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -114,8 +114,13 @@ typedef fp_except fp_except_t;
inline void reset_floating_point_exceptions()
{
/* Don't fall for overflow, underflow,divide-by-zero or loss of precision */
- fpsetmask(~(FP_X_INV | FP_X_DNML | FP_X_OFL | FP_X_UFL |
- FP_X_DZ | FP_X_IMP));
+#if defined(__i386__)
+ fpsetmask(~(FP_X_INV | FP_X_DNML | FP_X_OFL | FP_X_UFL | FP_X_DZ |
+ FP_X_IMP));
+else
+ fpsetmask(~(FP_X_INV | FP_X_OFL | FP_X_UFL | FP_X_DZ |
+ FP_X_IMP));
+#endif
}
#else
#define reset_floating_point_exceptions()
@@ -390,6 +395,7 @@ static void get_options(int argc,char **argv);
static char *get_relative_path(const char *path);
static void fix_paths(void);
static pthread_handler_decl(handle_connections_sockets,arg);
+static pthread_handler_decl(kill_server_thread,arg);
static int bootstrap(FILE *file);
static void close_server_sock();
static bool read_init_file(char *file_name);
@@ -625,19 +631,26 @@ void kill_mysql(void)
#elif defined(OS2)
pthread_cond_signal( &eventShutdown); // post semaphore
#elif defined(HAVE_PTHREAD_KILL)
- if (pthread_kill(signal_thread,SIGTERM)) /* End everything nicely */
- {
- DBUG_PRINT("error",("Got error %d from pthread_kill",errno)); /* purecov: inspected */
- }
-#else
- kill(current_pid,SIGTERM);
+ if (pthread_kill(signal_thread,SIGTERM)) /* End everything nicely */
+ {
+ DBUG_PRINT("error",("Got error %d from pthread_kill",errno)); /* purecov: inspected */
+ }
+#elif !defined(SIGNALS_DONT_BREAK_READ)
+ kill(current_pid,SIGTERM);
#endif
- DBUG_PRINT("quit",("After pthread_kill"));
- shutdown_in_progress=1; // Safety if kill didn't work
-#ifdef SIGNALS_DONT_BREAK_READ
+ DBUG_PRINT("quit",("After pthread_kill"));
+ shutdown_in_progress=1; // Safety if kill didn't work
+#ifdef SIGNALS_DONT_BREAK_READ
+ if (!abort_loop)
+ {
+ pthread_t tmp;
abort_loop=1;
+ if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
+ (void*) 0))
+ sql_print_error("Error: Can't create thread to kill server");
+ }
#endif
- DBUG_VOID_RETURN;
+ DBUG_VOID_RETURN;
}
@@ -682,7 +695,7 @@ static void __cdecl kill_server(int sig_ptr)
#ifdef USE_ONE_SIGNAL_HAND
-pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
+static pthread_handler_decl(kill_server_thread,arg __attribute__((unused)))
{
my_thread_init(); // Initialize new thread
kill_server(0);
@@ -1474,7 +1487,7 @@ static void *signal_hand(void *arg __attribute__((unused)))
(void*) sig))
sql_print_error("Error: Can't create thread to kill server");
#else
- kill_server((void*) sig); // MIT THREAD has a alarm thread
+ kill_server((void*) sig); // MIT THREAD has a alarm thread
#endif
}
break;
@@ -2452,18 +2465,21 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
fromhost(&req);
if (!hosts_access(&req))
{
- // This may be stupid but refuse() includes an exit(0)
- // which we surely don't want...
- // clean_exit() - same stupid thing ...
+ /*
+ This may be stupid but refuse() includes an exit(0)
+ which we surely don't want...
+ clean_exit() - same stupid thing ...
+ */
syslog(deny_severity, "refused connect from %s", eval_client(&req));
if (req.sink)
((void (*)(int))req.sink)(req.fd);
- // C++ sucks (the gibberish in front just translates the supplied
- // sink function pointer in the req structure from a void (*sink)();
- // to a void(*sink)(int) if you omit the cast, the C++ compiler
- // will cry...
-
+ /*
+ C++ sucks (the gibberish in front just translates the supplied
+ sink function pointer in the req structure from a void (*sink)();
+ to a void(*sink)(int) if you omit the cast, the C++ compiler
+ will cry...
+ */
(void) shutdown(new_sock,2); // This looks fine to me...
(void) closesocket(new_sock);
continue;
@@ -2491,7 +2507,8 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
if (!(thd= new THD))
{
- (void) shutdown(new_sock,2); VOID(closesocket(new_sock));
+ (void) shutdown(new_sock,2);
+ VOID(closesocket(new_sock));
continue;
}
if (!(vio_tmp=vio_new(new_sock,
@@ -3158,7 +3175,7 @@ struct show_var_st status_vars[]= {
{"Com_drop_table", (char*) (com_stat+(uint) SQLCOM_DROP_TABLE),SHOW_LONG},
{"Com_flush", (char*) (com_stat+(uint) SQLCOM_FLUSH),SHOW_LONG},
{"Com_grant", (char*) (com_stat+(uint) SQLCOM_GRANT),SHOW_LONG},
- {"Com_ha_close", (char*) (com_stat+(uint) SQLCOM_HA_OPEN),SHOW_LONG},
+ {"Com_ha_close", (char*) (com_stat+(uint) SQLCOM_HA_CLOSE),SHOW_LONG},
{"Com_ha_open", (char*) (com_stat+(uint) SQLCOM_HA_OPEN),SHOW_LONG},
{"Com_ha_read", (char*) (com_stat+(uint) SQLCOM_HA_READ),SHOW_LONG},
{"Com_insert", (char*) (com_stat+(uint) SQLCOM_INSERT),SHOW_LONG},
@@ -4283,16 +4300,17 @@ static uint set_maximum_open_files(uint max_file_limit)
rlimit.rlim_cur=rlimit.rlim_max=max_file_limit;
if (setrlimit(RLIMIT_NOFILE,&rlimit))
{
- sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %ld",
- old_cur); /* purecov: inspected */
+ sql_print_error("Warning: setrlimit couldn't increase number of open files to more than %lu (request: %u)",
+ old_cur, max_file_limit); /* purecov: inspected */
max_file_limit=old_cur;
}
else
{
(void) getrlimit(RLIMIT_NOFILE,&rlimit);
if ((uint) rlimit.rlim_cur != max_file_limit)
- sql_print_error("Warning: setrlimit returned ok, but didn't change limits. Max open files is %ld",
- (ulong) rlimit.rlim_cur); /* purecov: inspected */
+ sql_print_error("Warning: setrlimit returned ok, but didn't change limits. Max open files is %ld (request: %u)",
+ (ulong) rlimit.rlim_cur,
+ max_file_limit); /* purecov: inspected */
max_file_limit=rlimit.rlim_cur;
}
}
diff --git a/sql/slave.cc b/sql/slave.cc
index 45d4a33031a..33c4273bcb0 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -766,9 +766,7 @@ int show_master_info(THD* thd)
net_store_data(packet, (longlong) glob_mi.pos);
last_log_seq = glob_mi.last_log_seq;
pthread_mutex_unlock(&glob_mi.lock);
- pthread_mutex_lock(&LOCK_slave); // QQ; This is not needed
net_store_data(packet, slave_running ? "Yes":"No");
- pthread_mutex_unlock(&LOCK_slave); // QQ; This is not needed
net_store_data(packet, &replicate_do_db);
net_store_data(packet, &replicate_ignore_db);
net_store_data(packet, (uint32)last_slave_errno);
@@ -1099,6 +1097,8 @@ slave_begin:
THD *thd; // needs to be first for thread_stack
MYSQL *mysql = NULL ;
char llbuff[22];
+ bool retried_once = 0;
+ ulonglong last_failed_pos = 0;
pthread_mutex_lock(&LOCK_slave);
if (!server_id)
@@ -1123,10 +1123,6 @@ slave_begin:
pthread_cond_broadcast(&COND_slave_start);
pthread_mutex_unlock(&LOCK_slave);
- // int error = 1;
- bool retried_once = 0;
- ulonglong last_failed_pos = 0;
-
// needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff
my_thread_init();
slave_thd = thd = new THD; // note that contructor of THD uses DBUG_ !
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 387bca35d08..c4dc56620d8 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1951,11 +1951,35 @@ Query_cache::get_free_block(ulong len, my_bool not_less, ulong min)
if (bins[start].number != 0)
{
Query_cache_block *list = bins[start].free_blocks;
- first = list;
- while (first->next != list && first->length < len)
- first=first->next;
- if (first->length >= len)
- block=first;
+ ulong max_len = list->prev->length;
+ if (list->prev->length >= len) // check block with max size
+ {
+ first = list;
+ uint n = 0;
+ while ( n < QUERY_CACHE_MEM_BIN_TRY &&
+ first->length < len) //we don't need irst->next != list
+ {
+ first=first->next;
+ n++;
+ }
+ if (first->length >= len)
+ block=first;
+ else // we don't need if (first->next != list)
+ {
+ n = 0;
+ block = list->prev;
+ while (n < QUERY_CACHE_MEM_BIN_TRY &&
+ block->length > len)
+ {
+ block=block->prev;
+ n++;
+ }
+ if(block->length < len)
+ block=block->next;
+ }
+ }
+ else
+ first = list->prev;
}
if (block == 0 && start > 0)
{
@@ -2117,18 +2141,28 @@ void Query_cache::insert_into_free_memory_list(Query_cache_block *free_block)
uint Query_cache::find_bin(ulong size)
{
- int i;
DBUG_ENTER("Query_cache::find_bin");
- // Begin small blocks to big (small blocks frequently asked)
- for (i=mem_bin_steps - 1; i > 0 && steps[i-1].size < size; i--) ;
- if (i == 0)
+ // Binary search
+ int left = 0, right = mem_bin_steps;
+ do
+ {
+ int middle = (left + right) / 2;
+ if (steps[middle].size > size)
+ left = middle+1;
+ else
+ right = middle;
+ } while (left < right);
+ if (left == 0)
{
// first bin not subordinate of common rules
DBUG_PRINT("qcache", ("first bin (# 0), size %lu",size));
DBUG_RETURN(0);
}
- uint bin = steps[i].idx - (uint)((size - steps[i].size)/steps[i].increment);
- DBUG_PRINT("qcache", ("bin %u step %u, size %lu", bin, i, size));
+ uint bin = steps[left].idx -
+ (uint)((size - steps[left].size)/steps[left].increment);
+ bins_dump();
+ DBUG_PRINT("qcache", ("bin %u step %u, size %lu step size %lu",
+ bin, left, size, steps[left].size));
DBUG_RETURN(bin);
}
@@ -2480,6 +2514,9 @@ my_bool Query_cache::move_by_type(byte **border,
result_block = result_block->next;
} while ( result_block != first_result_block );
}
+ Query_cache_query *new_query= ((Query_cache_query *) new_block->data());
+ pthread_cond_init(&new_query->lock, NULL);
+ pthread_mutex_init(&new_query->clients_guard,MY_MUTEX_INIT_FAST);
NET *net = new_block->query()->writer();
if (net != 0)
{
diff --git a/sql/sql_cache.h b/sql/sql_cache.h
index da7ada14f23..6f8d9bb6dbf 100644
--- a/sql/sql_cache.h
+++ b/sql/sql_cache.h
@@ -41,6 +41,10 @@
#define QUERY_CACHE_MEM_BIN_PARTS_MUL 1.2
#define QUERY_CACHE_MEM_BIN_SPC_LIM_PWR2 3
+/* how many free blocks check when finding most suitable before other 'end'
+ of list of free blocks */
+#define QUERY_CACHE_MEM_BIN_TRY 5
+
/* query flags masks */
#define QUERY_CACHE_CLIENT_LONG_FLAG_MASK 0x80
#define QUERY_CACHE_CHARSET_CONVERT_MASK 0x7F
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index c044d17f0a9..215a6723db9 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -875,8 +875,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}
thd->free_list=0;
table_list.name=table_list.real_name=thd->strdup(packet);
- thd->query=fields=thd->strdup(strend(packet)+1);
- thd->query_length=strlen(thd->query);
+ packet=strend(packet)+1;
+ if (!(thd->query=fields=thd->memdup(packet,thd->query_length+1)))
+ break;
mysql_log.write(thd,command,"%s %s",table_list.real_name,fields);
remove_escape(table_list.real_name); // This can't have wildcards
diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c
index 5130838c99e..c8b7803790c 100644
--- a/tools/mysqlmanager.c
+++ b/tools/mysqlmanager.c
@@ -653,14 +653,14 @@ HANDLE_DECL(handle_stop_exec)
e->th=pthread_self();
if (!e->pid)
{
- e->th=0;
+ /* e->th=0; */ /* th may be a struct */
pthread_mutex_unlock(&e->lock);
error="Process not running";
goto err;
}
if (mysql_shutdown(&e->mysql))
{
- e->th=0;
+ /* e->th=0; */ /* th may be a struct */
pthread_mutex_unlock(&e->lock);
error="Could not send shutdown command";
goto err;
@@ -669,7 +669,7 @@ HANDLE_DECL(handle_stop_exec)
pthread_cond_timedwait(&e->cond,&e->lock,&abstime);
if (e->pid)
error="Process failed to terminate within alotted time";
- e->th=0;
+ /* e->th=0; */ /* th may be a struct */
pthread_mutex_unlock(&e->lock);
if (!error)
{
@@ -1378,7 +1378,6 @@ static int run_server_loop()
pthread_t th;
struct manager_thd *thd;
int client_sock;
- uint len;
Vio* vio;
pthread_attr_t thr_attr;
(void) pthread_attr_init(&thr_attr);
@@ -1389,7 +1388,7 @@ static int run_server_loop()
for (;!shutdown_requested;)
{
- len=sizeof(struct sockaddr_in);
+ size_socket len=sizeof(struct sockaddr_in);
if ((client_sock=accept(manager_sock,(struct sockaddr*)&manager_addr,
&len)) <0)
{