Browse Source

branches/zip: Treat mem_hash_mutex specially in mutex_free(),

and explicitly free mem_hash_mutex in mem_close().
This fixes the breakage of UNIV_MEM_DEBUG that was filed as Issue #434.
pull/73/head
marko 16 years ago
parent
commit
1550a7253b
  1. 7
      include/mem0dbg.h
  2. 3
      include/mem0dbg.ic
  3. 4
      mem/mem0dbg.c
  4. 19
      sync/sync0sync.c

7
include/mem0dbg.h

@ -28,6 +28,13 @@ Created 6/9/1994 Heikki Tuuri
check fields whose sizes are given below */
#ifdef UNIV_MEM_DEBUG
# ifndef UNIV_HOTBACKUP
/* The mutex which protects in the debug version the hash table
containing the list of live memory heaps, and also the global
variables in mem0dbg.c. */
extern mutex_t mem_hash_mutex;
# endif /* !UNIV_HOTBACKUP */
#define MEM_FIELD_HEADER_SIZE ut_calc_align(2 * sizeof(ulint),\
UNIV_MEM_ALIGNMENT)
#define MEM_FIELD_TRAILER_SIZE sizeof(ulint)

3
include/mem0dbg.ic

@ -25,9 +25,6 @@ Created 6/8/1994 Heikki Tuuri
*************************************************************************/
#ifdef UNIV_MEM_DEBUG
# ifndef UNIV_HOTBACKUP
extern mutex_t mem_hash_mutex;
# endif /* !UNIV_HOTBACKUP */
extern ulint mem_current_allocated_memory;
/******************************************************************//**

4
mem/mem0dbg.c

@ -180,6 +180,10 @@ mem_close(void)
{
mem_pool_free(mem_comm_pool);
mem_comm_pool = NULL;
#ifdef UNIV_MEM_DEBUG
mutex_free(&mem_hash_mutex);
mem_hash_initialized = FALSE;
#endif /* UNIV_MEM_DEBUG */
}
#endif /* !UNIV_HOTBACKUP */

19
sync/sync0sync.c

@ -315,6 +315,15 @@ mutex_free(
ut_a(mutex_get_lock_word(mutex) == 0);
ut_a(mutex_get_waiters(mutex) == 0);
#ifdef UNIV_MEM_DEBUG
if (mutex == &mem_hash_mutex) {
ut_ad(UT_LIST_GET_LEN(mutex_list) == 1);
ut_ad(UT_LIST_GET_FIRST(mutex_list) == &mem_hash_mutex);
UT_LIST_REMOVE(list, mutex_list, mutex);
goto func_exit;
}
#endif /* UNIV_MEM_DEBUG */
if (mutex != &mutex_list_mutex
#ifdef UNIV_SYNC_DEBUG
&& mutex != &sync_thread_mutex
@ -336,7 +345,9 @@ mutex_free(
}
os_event_free(mutex->event);
#ifdef UNIV_MEM_DEBUG
func_exit:
#endif /* UNIV_MEM_DEBUG */
#if !defined(HAVE_ATOMIC_BUILTINS)
os_fast_mutex_free(&(mutex->os_fast_mutex));
#endif
@ -1370,6 +1381,12 @@ sync_close(void)
mutex = UT_LIST_GET_FIRST(mutex_list);
while (mutex) {
#ifdef UNIV_MEM_DEBUG
if (mutex == &mem_hash_mutex) {
mutex = UT_LIST_GET_NEXT(list, mutex);
continue;
}
#endif /* UNIV_MEM_DEBUG */
mutex_free(mutex);
mutex = UT_LIST_GET_FIRST(mutex_list);
}

Loading…
Cancel
Save