~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Andrew Hutchings
  • Date: 2010-11-09 13:38:01 UTC
  • mto: (1919.1.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 1920.
  • Revision ID: andrew@linuxjedi.co.uk-20101109133801-byjzsao76346395x
Add FLUSH GLOBAL STATUS; command
Clears the global status variables for the server

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1994, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
24
24
*************************************************************************/
25
25
 
26
26
#include "mem0mem.h"
27
 
 
28
27
#ifdef UNIV_NONINL
29
28
#include "mem0mem.ic"
30
29
#endif
31
30
 
32
31
#include "buf0buf.h"
33
32
#include "srv0srv.h"
34
 
#include "mem0dbg.cc"
 
33
#include "mem0dbg.c"
35
34
#include <stdarg.h>
36
35
 
37
36
/*
109
108
        mem_heap_t*     heap,   /*!< in: memory heap where string is allocated */
110
109
        const char*     str)    /*!< in: string to be copied */
111
110
{
112
 
        return(static_cast<char *>(mem_heap_dup(heap, str, strlen(str) + 1)));
 
111
        return(mem_heap_dup(heap, str, strlen(str) + 1));
113
112
}
114
113
 
115
114
/**********************************************************************//**
141
140
        ulint   s1_len = strlen(s1);
142
141
        ulint   s2_len = strlen(s2);
143
142
 
144
 
        s = static_cast<char *>(mem_heap_alloc(heap, s1_len + s2_len + 1));
 
143
        s = mem_heap_alloc(heap, s1_len + s2_len + 1);
145
144
 
146
145
        memcpy(s, s1, s1_len);
147
146
        memcpy(s + s1_len, s2, s2_len);
286
285
        va_end(ap);
287
286
 
288
287
        /* Now create it for real. */
289
 
        str = static_cast<char *>(mem_heap_alloc(heap, len));
 
288
        str = mem_heap_alloc(heap, len);
290
289
        va_start(ap, format);
291
290
        mem_heap_printf_low(str, format, ap);
292
291
        va_end(ap);
331
330
 
332
331
                ut_ad(type == MEM_HEAP_DYNAMIC || n <= MEM_MAX_ALLOC_IN_BUF);
333
332
 
334
 
                block = static_cast<mem_block_info_t *>(mem_area_alloc(&len, mem_comm_pool));
 
333
                block = mem_area_alloc(&len, mem_comm_pool);
335
334
        } else {
336
335
                len = UNIV_PAGE_SIZE;
337
336
 
340
339
                        buffer pool, but must get the free block from
341
340
                        the heap header free block field */
342
341
 
343
 
                        buf_block = static_cast<buf_block_t *>(heap->free_block);
 
342
                        buf_block = heap->free_block;
344
343
                        heap->free_block = NULL;
345
344
 
346
345
                        if (UNIV_UNLIKELY(!buf_block)) {
348
347
                                return(NULL);
349
348
                        }
350
349
                } else {
351
 
                        buf_block = buf_block_alloc(NULL, 0);
 
350
                        buf_block = buf_block_alloc(0);
352
351
                }
353
352
 
354
353
                block = (mem_block_t*) buf_block->frame;
368
367
        block->line = line;
369
368
 
370
369
#ifdef MEM_PERIODIC_CHECK
371
 
        mutex_enter(&(mem_comm_pool->mutex));
 
370
        mem_pool_mutex_enter();
372
371
 
373
372
        if (!mem_block_list_inited) {
374
373
                mem_block_list_inited = TRUE;
377
376
 
378
377
        UT_LIST_ADD_LAST(mem_block_list, mem_block_list, block);
379
378
 
380
 
        mutex_exit(&(mem_comm_pool->mutex));
 
379
        mem_pool_mutex_exit();
381
380
#endif
382
381
        mem_block_set_len(block, len);
383
382
        mem_block_set_type(block, type);
384
383
        mem_block_set_free(block, MEM_BLOCK_HEADER_SIZE);
385
384
        mem_block_set_start(block, MEM_BLOCK_HEADER_SIZE);
386
385
 
387
 
        if (UNIV_UNLIKELY(heap == NULL)) {
388
 
                /* This is the first block of the heap. The field
389
 
                total_size should be initialized here */
390
 
                block->total_size = len;
391
 
        } else {
392
 
                /* Not the first allocation for the heap. This block's
393
 
                total_length field should be set to undefined. */
394
 
                ut_d(block->total_size = ULINT_UNDEFINED);
395
 
                UNIV_MEM_INVALID(&block->total_size,
396
 
                                 sizeof block->total_size);
397
 
 
398
 
                heap->total_size += len;
399
 
        }
400
 
 
401
386
        ut_ad((ulint)MEM_BLOCK_HEADER_SIZE < len);
402
387
 
403
388
        return(block);
470
455
        ulint           type;
471
456
        ulint           len;
472
457
#ifndef UNIV_HOTBACKUP
473
 
        buf_block_t*    buf_block       = static_cast<buf_block_t *>(block->buf_block);
 
458
        buf_block_t*    buf_block       = block->buf_block;
474
459
#endif /* !UNIV_HOTBACKUP */
475
460
 
476
461
        if (block->magic_n != MEM_BLOCK_MAGIC_N) {
480
465
        UT_LIST_REMOVE(list, heap->base, block);
481
466
 
482
467
#ifdef MEM_PERIODIC_CHECK
483
 
        mutex_enter(&(mem_comm_pool->mutex));
 
468
        mem_pool_mutex_enter();
484
469
 
485
470
        UT_LIST_REMOVE(mem_block_list, mem_block_list, block);
486
471
 
487
 
        mutex_exit(&(mem_comm_pool->mutex));
 
472
        mem_pool_mutex_exit();
488
473
#endif
489
 
 
490
 
        ut_ad(heap->total_size >= block->len);
491
 
        heap->total_size -= block->len;
492
 
 
493
474
        type = heap->type;
494
475
        len = block->len;
495
476
        block->magic_n = MEM_FREED_BLOCK_MAGIC_N;
537
518
{
538
519
        if (UNIV_LIKELY_NULL(heap->free_block)) {
539
520
 
540
 
                buf_block_free(static_cast<buf_block_t *>(heap->free_block));
 
521
                buf_block_free(heap->free_block);
541
522
 
542
523
                heap->free_block = NULL;
543
524
        }
555
536
{
556
537
        mem_block_t*    block;
557
538
 
558
 
        mutex_enter(&(mem_comm_pool->mutex));
 
539
        mem_pool_mutex_enter();
559
540
 
560
541
        block = UT_LIST_GET_FIRST(mem_block_list);
561
542
 
567
548
                block = UT_LIST_GET_NEXT(mem_block_list, block);
568
549
        }
569
550
 
570
 
        mutex_exit(&(mem_comm_pool->mutex));
 
551
        mem_pool_mutex_exit();
571
552
}
572
553
#endif