summaryrefslogtreecommitdiff
path: root/innobase/mem/mem0mem.c
diff options
context:
space:
mode:
authorunknown <heikki@donna.mysql.fi>2002-02-04 23:55:41 +0200
committerunknown <heikki@donna.mysql.fi>2002-02-04 23:55:41 +0200
commit9871a6d080f507f58afa91bfd7624c27b27963cd (patch)
tree8afb00e0a5c01501d06fda6b055c26e219075b91 /innobase/mem/mem0mem.c
parent3518de828d1c7c384ea3503ae2ce1477bf4a9095 (diff)
downloadmariadb-git-9871a6d080f507f58afa91bfd7624c27b27963cd.tar.gz
Many files:
Small improvements row0mysql.c: Small improvements + fix the ALTER TABLE problem by introducing a lazy drop table it can use ha_innobase.cc: Some fine-tuning of optimization sql/ha_innobase.cc: Some fine-tuning of optimization innobase/include/log0recv.h: Small improvements innobase/include/mem0mem.h: Small improvements innobase/include/mem0pool.h: Small improvements innobase/include/row0mysql.h: Small improvements innobase/include/srv0srv.h: Small improvements innobase/include/trx0trx.h: Small improvements innobase/buf/buf0lru.c: Small improvements innobase/fil/fil0fil.c: Small improvements innobase/log/log0recv.c: Small improvements innobase/mem/mem0mem.c: Small improvements innobase/mem/mem0pool.c: Small improvements innobase/row/row0mysql.c: Small improvements + fix the ALTER TABLE problem by introducing a lazy drop table it can use innobase/srv/srv0srv.c: Small improvements innobase/srv/srv0start.c: Small improvements innobase/trx/trx0purge.c: Small improvements innobase/trx/trx0trx.c: Small improvements
Diffstat (limited to 'innobase/mem/mem0mem.c')
-rw-r--r--innobase/mem/mem0mem.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/innobase/mem/mem0mem.c b/innobase/mem/mem0mem.c
index 3e0a9c008f3..0680968a7eb 100644
--- a/innobase/mem/mem0mem.c
+++ b/innobase/mem/mem0mem.c
@@ -75,6 +75,14 @@ After freeing, all the blocks in the heap are set to random bytes
to help us discover errors which result from the use of
buffers in an already freed heap. */
+#ifdef MEM_PERIODIC_CHECK
+
+ibool mem_block_list_inited;
+/* List of all mem blocks allocated; protected by the mem_comm_pool mutex */
+UT_LIST_BASE_NODE_T(mem_block_t) mem_block_list;
+
+#endif
+
/*******************************************************************
NOTE: Use the corresponding macro instead of this function.
Allocates a single buffer of memory from the dynamic memory of
@@ -169,7 +177,19 @@ mem_heap_create_block(
7);
block->file_name[7]='\0';
block->line = line;
+
+#ifdef MEM_PERIODIC_CHECK
+ mem_pool_mutex_enter();
+
+ if (!mem_block_list_inited) {
+ mem_block_list_inited = TRUE;
+ UT_LIST_INIT(mem_block_list);
+ }
+ UT_LIST_ADD_LAST(mem_block_list, mem_block_list, block);
+
+ mem_pool_mutex_exit();
+#endif
mem_block_set_len(block, len);
mem_block_set_type(block, type);
mem_block_set_free(block, MEM_BLOCK_HEADER_SIZE);
@@ -261,6 +281,13 @@ mem_heap_block_free(
UT_LIST_REMOVE(list, heap->base, block);
+#ifdef MEM_PERIODIC_CHECK
+ mem_pool_mutex_enter();
+
+ UT_LIST_REMOVE(mem_block_list, mem_block_list, block);
+
+ mem_pool_mutex_exit();
+#endif
type = heap->type;
len = block->len;
init_block = block->init_block;
@@ -306,3 +333,30 @@ mem_heap_free_block_free(
heap->free_block = NULL;
}
}
+
+#ifdef MEM_PERIODIC_CHECK
+/**********************************************************************
+Goes through the list of all allocated mem blocks, checks their magic
+numbers, and reports possible corruption. */
+
+void
+mem_validate_all_blocks(void)
+/*=========================*/
+{
+ mem_block_t* block;
+
+ mem_pool_mutex_enter();
+
+ block = UT_LIST_GET_FIRST(mem_block_list);
+
+ while (block) {
+ if (block->magic_n != MEM_BLOCK_MAGIC_N) {
+ mem_analyze_corruption((byte*)block);
+ }
+
+ block = UT_LIST_GET_NEXT(mem_block_list, block);
+ }
+
+ mem_pool_mutex_exit();
+}
+#endif