~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/mem/mem0pool.c

  • Committer: Monty Taylor
  • Date: 2010-11-26 22:50:54 UTC
  • mfrom: (1953.1.6 build)
  • Revision ID: mordred@inaugust.com-20101126225054-sg90svw8579t5p3i
Stewart - InnoDB 1.1.1
Monty - Fixed some autoconf tests which were returning false positives.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include "ut0lst.h"
35
35
#include "ut0byte.h"
36
36
#include "mem0mem.h"
 
37
#include "srv0start.h"
37
38
 
38
39
/* We would like to use also the buffer frames to allocate memory. This
39
40
would be desirable, because then the memory consumption of the database
114
115
/** The common memory pool */
115
116
UNIV_INTERN mem_pool_t* mem_comm_pool   = NULL;
116
117
 
 
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 */
 
122
 
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;
122
128
 
123
129
/********************************************************************//**
124
 
Reserves the mem pool mutex. */
125
 
UNIV_INTERN
 
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. */
 
133
UNIV_INLINE
126
134
void
127
 
mem_pool_mutex_enter(void)
128
 
/*======================*/
 
135
mem_pool_mutex_enter(
 
136
/*=================*/
 
137
        mem_pool_t*     pool)           /*!< in: memory pool */
129
138
{
130
 
        mutex_enter(&(mem_comm_pool->mutex));
 
139
        if (srv_shutdown_state < SRV_SHUTDOWN_EXIT_THREADS) {
 
140
                mutex_enter(&(pool->mutex));
 
141
        }
131
142
}
132
143
 
133
144
/********************************************************************//**
134
 
Releases the mem pool mutex. */
135
 
UNIV_INTERN
 
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 */
 
148
UNIV_INLINE
136
149
void
137
 
mem_pool_mutex_exit(void)
138
 
/*=====================*/
 
150
mem_pool_mutex_exit(
 
151
/*================*/
 
152
        mem_pool_t*     pool)           /*!< in: memory pool */
139
153
{
140
 
        mutex_exit(&(mem_comm_pool->mutex));
 
154
        if (srv_shutdown_state < SRV_SHUTDOWN_EXIT_THREADS) {
 
155
                mutex_exit(&(pool->mutex));
 
156
        }
141
157
}
142
158
 
143
159
/********************************************************************//**
219
235
        pool->buf = ut_malloc_low(size, FALSE, TRUE);
220
236
        pool->size = size;
221
237
 
222
 
        mutex_create(&pool->mutex, SYNC_MEM_POOL);
 
238
        mutex_create(mem_pool_mutex_key, &pool->mutex, SYNC_MEM_POOL);
223
239
 
224
240
        /* Initialize the free lists */
225
241
 
567
583
 
568
584
        n = ut_2_log(size);
569
585
 
570
 
        mutex_enter(&(pool->mutex));
 
586
        mem_pool_mutex_enter(pool);
571
587
        mem_n_threads_inside++;
572
588
 
573
589
        ut_a(mem_n_threads_inside == 1);
595
611
                pool->reserved += ut_2_exp(n);
596
612
 
597
613
                mem_n_threads_inside--;
598
 
                mutex_exit(&(pool->mutex));
 
614
                mem_pool_mutex_exit(pool);
599
615
 
600
616
                mem_area_free(new_ptr, pool);
601
617
 
611
627
        }
612
628
 
613
629
        mem_n_threads_inside--;
614
 
        mutex_exit(&(pool->mutex));
 
630
        mem_pool_mutex_exit(pool);
615
631
 
616
632
        ut_ad(mem_pool_validate(pool));
617
633
}
630
646
        ulint           free;
631
647
        ulint           i;
632
648
 
633
 
        mutex_enter(&(pool->mutex));
 
649
        mem_pool_mutex_enter(pool);
634
650
 
635
651
        free = 0;
636
652
 
658
674
 
659
675
        ut_a(free + pool->reserved == pool->size);
660
676
 
661
 
        mutex_exit(&(pool->mutex));
 
677
        mem_pool_mutex_exit(pool);
662
678
 
663
679
        return(TRUE);
664
680
}