summaryrefslogtreecommitdiff
path: root/sql/ha_berkeley.cc
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2000-12-16 23:41:45 +0200
committerunknown <monty@donna.mysql.com>2000-12-16 23:41:45 +0200
commit289de3ff9d278a61e28d854b9010cc7967b9dc11 (patch)
treea884910ed118d34b9de837e52be9e458c4b8619d /sql/ha_berkeley.cc
parent77a3ea5103f73aac2e3c8868abb2c93c8d01184b (diff)
downloadmariadb-git-289de3ff9d278a61e28d854b9010cc7967b9dc11.tar.gz
Fixed error when copying mysqld_multi
Fixes for mysql-test Fixed race condition in SHOW LOGS BUILD/compile-solaris-sparc: cleanup Build-tools/Do-compile: Fixed problem Makefile.am: Merged tests with benchmarks configure.in: Fix for Solaris 2.8 scripts/Makefile.am: Fixed error when copying mysqld_multi scripts/make_binary_distribution.sh: Fixes for mysql-test sql/ha_berkeley.cc: Fixed race condition in SHOW LOGS sql/mysqld.cc: Fixed bug in networking
Diffstat (limited to 'sql/ha_berkeley.cc')
-rw-r--r--sql/ha_berkeley.cc35
1 files changed, 20 insertions, 15 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index 1a29de32ed4..bd2e4ee9272 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -93,7 +93,6 @@ u_int32_t berkeley_lock_types[]=
{ DB_LOCK_DEFAULT, DB_LOCK_OLDEST, DB_LOCK_RANDOM };
TYPELIB berkeley_lock_typelib= {array_elements(berkeley_lock_names),"",
berkeley_lock_names};
-static MEM_ROOT show_logs_root;
static void berkeley_print_error(const char *db_errpfx, char *buffer);
static byte* bdb_get_key(BDB_SHARE *share,uint *length,
@@ -211,45 +210,51 @@ int berkeley_rollback(THD *thd, void *trans)
DBUG_RETURN(error);
}
-static void *show_logs_alloc(size_t size)
-{
- return alloc_root(&show_logs_root, size);
-}
int berkeley_show_logs(THD *thd)
{
- char **all_logs, **free_logs;
+ char **all_logs, **free_logs, **a, **f;
String *packet= &thd->packet;
- int error;
+ int error=1;
+ MEM_ROOT show_logs_root;
+ MEM_ROOT *old_root=my_pthread_getspecific_ptr(MEM_ROOT*,THR_MALLOC);
DBUG_ENTER("berkeley_show_logs");
init_alloc_root(&show_logs_root, 1024, 1024);
- if ((error= log_archive(db_env, &all_logs, DB_ARCH_ABS|DB_ARCH_LOG, show_logs_alloc)) ||
- (error= log_archive(db_env, &free_logs, DB_ARCH_ABS, show_logs_alloc)))
+ my_pthread_setspecific_ptr(THR_MALLOC,&show_logs_root);
+
+ if ((error= log_archive(db_env, &all_logs, DB_ARCH_ABS | DB_ARCH_LOG,
+ (void* (*)(unsigned int)) sql_alloc)) ||
+ (error= log_archive(db_env, &free_logs, DB_ARCH_ABS,
+ (void* (*)(unsigned int)) sql_alloc)))
{
DBUG_PRINT("error", ("log_archive failed (error %d)", error));
db_env->err(db_env, error, "log_archive: DB_ARCH_ABS");
- DBUG_RETURN(1);
+ goto err;
}
- for (char **a = all_logs, **f = free_logs; *a; ++a)
+ for (a = all_logs, f = free_logs; *a; ++a)
{
packet->length(0);
net_store_data(packet,*a);
net_store_data(packet,"BDB");
- if (f && *f && strcmp(*a, *f) == 0)
+ if (*f && strcmp(*a, *f) == 0)
{
- net_store_data(packet, SHOW_LOG_STATUS_FREE);
++f;
+ net_store_data(packet, SHOW_LOG_STATUS_FREE);
}
else
net_store_data(packet, SHOW_LOG_STATUS_INUSE);
if (my_net_write(&thd->net,(char*) packet->ptr(),packet->length()))
- DBUG_RETURN(1); /* purecov: inspected */
+ goto err;
}
+ error=0;
+
+err:
free_root(&show_logs_root,MYF(0));
- DBUG_RETURN(0);
+ my_pthread_setspecific_ptr(THR_MALLOC,old_root);
+ DBUG_RETURN(error);
}
static void berkeley_print_error(const char *db_errpfx, char *buffer)