114
115
/** The common memory pool */
115
116
UNIV_INTERN mem_pool_t* mem_comm_pool = NULL;
118
#ifdef UNIV_PFS_MUTEX
119
/* Key to register mutex in mem_pool_struct with performance schema */
120
UNIV_INTERN mysql_pfs_key_t mem_pool_mutex_key;
121
#endif /* UNIV_PFS_MUTEX */
117
123
/* We use this counter to check that the mem pool mutex does not leak;
118
124
this is to track a strange assertion failure reported at
119
125
mysql@lists.mysql.com */
121
127
UNIV_INTERN ulint mem_n_threads_inside = 0;
123
129
/********************************************************************//**
124
Reserves the mem pool mutex. */
130
Reserves the mem pool mutex if we are not in server shutdown. Use
131
this function only in memory free functions, since only memory
132
free functions are used during server shutdown. */
127
mem_pool_mutex_enter(void)
128
/*======================*/
135
mem_pool_mutex_enter(
136
/*=================*/
137
mem_pool_t* pool) /*!< in: memory pool */
130
mutex_enter(&(mem_comm_pool->mutex));
139
if (srv_shutdown_state < SRV_SHUTDOWN_EXIT_THREADS) {
140
mutex_enter(&(pool->mutex));
133
144
/********************************************************************//**
134
Releases the mem pool mutex. */
145
Releases the mem pool mutex if we are not in server shutdown. As
146
its corresponding mem_pool_mutex_enter() function, use it only
147
in memory free functions */
137
mem_pool_mutex_exit(void)
138
/*=====================*/
152
mem_pool_t* pool) /*!< in: memory pool */
140
mutex_exit(&(mem_comm_pool->mutex));
154
if (srv_shutdown_state < SRV_SHUTDOWN_EXIT_THREADS) {
155
mutex_exit(&(pool->mutex));
143
159
/********************************************************************//**
219
235
pool->buf = ut_malloc_low(size, FALSE, TRUE);
220
236
pool->size = size;
222
mutex_create(&pool->mutex, SYNC_MEM_POOL);
238
mutex_create(mem_pool_mutex_key, &pool->mutex, SYNC_MEM_POOL);
224
240
/* Initialize the free lists */
595
611
pool->reserved += ut_2_exp(n);
597
613
mem_n_threads_inside--;
598
mutex_exit(&(pool->mutex));
614
mem_pool_mutex_exit(pool);
600
616
mem_area_free(new_ptr, pool);