~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/sync/sync0arr.c

  • Committer: Brian Aker
  • Date: 2010-10-22 07:38:49 UTC
  • mto: This revision was merged to the branch mainline in revision 1885.
  • Revision ID: brian@tangent.org-20101022073849-h3j2eglp70dav2ze
Adds in a portion of the ref constraints table.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
4
 
Copyright (C) 2008, Google Inc.
 
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
 
4
Copyright (c) 2008, Google Inc.
5
5
 
6
6
Portions of this file contain modifications contributed and copyrighted by
7
7
Google, Inc. Those modifications are gratefully acknowledged and are described
138
138
                                        since creation of the array */
139
139
};
140
140
 
141
 
#ifdef UNIV_PFS_MUTEX
142
 
/* Key to register the mutex with performance schema */
143
 
UNIV_INTERN mysql_pfs_key_t     syn_arr_mutex_key;
144
 
#endif
145
 
 
146
141
#ifdef UNIV_SYNC_DEBUG
147
142
/******************************************************************//**
148
143
This function is called only in the debug version. Detects a deadlock
238
233
        ut_a(n_cells > 0);
239
234
 
240
235
        /* Allocate memory for the data structures */
241
 
        arr = static_cast<sync_array_t *>(ut_malloc(sizeof(sync_array_t)));
 
236
        arr = ut_malloc(sizeof(sync_array_t));
242
237
        memset(arr, 0x0, sizeof(*arr));
243
238
 
244
239
        sz = sizeof(sync_cell_t) * n_cells;
245
 
        arr->array = static_cast<sync_cell_t *>(ut_malloc(sz));
 
240
        arr->array = ut_malloc(sz);
246
241
        memset(arr->array, 0x0, sz);
247
242
 
248
243
        arr->n_cells = n_cells;
250
245
 
251
246
        /* Then create the mutex to protect the wait array complex */
252
247
        if (protection == SYNC_ARRAY_OS_MUTEX) {
253
 
                arr->os_mutex = os_mutex_create();
 
248
                arr->os_mutex = os_mutex_create(NULL);
254
249
        } else if (protection == SYNC_ARRAY_MUTEX) {
255
 
                mutex_create(syn_arr_mutex_key,
256
 
                             &arr->mutex, SYNC_NO_ORDER_CHECK);
 
250
                mutex_create(&arr->mutex, SYNC_NO_ORDER_CHECK);
257
251
        } else {
258
252
                ut_error;
259
253
        }
372
366
                        cell->wait_object = object;
373
367
 
374
368
                        if (type == SYNC_MUTEX) {
375
 
                                cell->old_wait_mutex = static_cast<mutex_struct *>(object);
 
369
                                cell->old_wait_mutex = object;
376
370
                        } else {
377
 
                                cell->old_wait_rw_lock = static_cast<rw_lock_struct *>(object);
 
371
                                cell->old_wait_rw_lock = object;
378
372
                        }
379
373
 
380
374
                        cell->request_type = type;
504
498
                   || type == RW_LOCK_WAIT_EX
505
499
                   || type == RW_LOCK_SHARED) {
506
500
 
507
 
                fputs(type == RW_LOCK_EX ? "X-lock on"
508
 
                      : type == RW_LOCK_WAIT_EX ? "X-lock (wait_ex) on"
509
 
                      : "S-lock on", file);
 
501
                fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
510
502
 
511
503
                rwlock = cell->old_wait_rw_lock;
512
504
 
783
775
 
784
776
        if (cell->request_type == SYNC_MUTEX) {
785
777
 
786
 
                mutex = static_cast<mutex_t *>(cell->wait_object);
 
778
                mutex = cell->wait_object;
787
779
 
788
780
                if (mutex_get_lock_word(mutex) == 0) {
789
781
 
792
784
 
793
785
        } else if (cell->request_type == RW_LOCK_EX) {
794
786
 
795
 
                lock = static_cast<rw_lock_t *>(cell->wait_object);
 
787
                lock = cell->wait_object;
796
788
 
797
789
                if (lock->lock_word > 0) {
798
790
                /* Either unlocked or only read locked. */
802
794
 
803
795
        } else if (cell->request_type == RW_LOCK_WAIT_EX) {
804
796
 
805
 
                lock = static_cast<rw_lock_t *>(cell->wait_object);
 
797
                lock = cell->wait_object;
806
798
 
807
799
                /* lock_word == 0 means all readers have left */
808
800
                if (lock->lock_word == 0) {
810
802
                        return(TRUE);
811
803
                }
812
804
        } else if (cell->request_type == RW_LOCK_SHARED) {
813
 
                lock = static_cast<rw_lock_t *>(cell->wait_object);
 
805
                lock = cell->wait_object;
814
806
 
815
807
                /* lock_word > 0 means no writer or reserved writer */
816
808
                if (lock->lock_word > 0) {