~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Lee Bieber
  • Date: 2010-11-07 19:34:48 UTC
  • mfrom: (1910.1.2 build)
  • Revision ID: kalebral@gmail.com-20101107193448-64kdu912qej354sh
Merge Stewart - including adapting and expanding the "differences from mysql" page from the wiki.
Merge Stewart - fix bug 668143: drizzleslap with --commit runs second iteration data load in a transaction

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
168
168
UNIV_INTERN rw_lock_list_t      rw_lock_list;
169
169
UNIV_INTERN mutex_t             rw_lock_list_mutex;
170
170
 
171
 
#ifdef UNIV_PFS_MUTEX
172
 
UNIV_INTERN mysql_pfs_key_t     rw_lock_list_mutex_key;
173
 
UNIV_INTERN mysql_pfs_key_t     rw_lock_mutex_key;
174
 
#endif /* UNIV_PFS_MUTEX */
175
 
 
176
171
#ifdef UNIV_SYNC_DEBUG
177
172
/* The global mutex which protects debug info lists of all rw-locks.
178
173
To modify the debug info list of an rw-lock, this mutex has to be
179
174
acquired in addition to the mutex protecting the lock. */
180
175
 
181
176
UNIV_INTERN mutex_t             rw_lock_debug_mutex;
182
 
 
183
 
# ifdef UNIV_PFS_MUTEX
184
 
UNIV_INTERN mysql_pfs_key_t     rw_lock_debug_mutex_key;
185
 
# endif
186
 
 
187
177
/* If deadlock detection does not get immediately the mutex,
188
178
it may wait for this event */
189
179
UNIV_INTERN os_event_t          rw_lock_debug_event;
241
231
# ifdef UNIV_SYNC_DEBUG
242
232
        ulint           level,          /*!< in: level */
243
233
# endif /* UNIV_SYNC_DEBUG */
244
 
        const char*     cmutex_name,    /*!< in: mutex name */
 
234
        const char*     cmutex_name,    /*!< in: mutex name */
245
235
#endif /* UNIV_DEBUG */
246
236
        const char*     cfile_name,     /*!< in: file name where created */
247
237
        ulint           cline)          /*!< in: file line where created */
250
240
        created, then the following call initializes the sync system. */
251
241
 
252
242
#ifndef INNODB_RW_LOCKS_USE_ATOMICS
253
 
        mutex_create(rw_lock_mutex_key, rw_lock_get_mutex(lock),
254
 
                     SYNC_NO_ORDER_CHECK);
 
243
        mutex_create(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
255
244
 
256
245
        lock->mutex.cfile_name = cfile_name;
257
246
        lock->mutex.cline = cline;
278
267
        lock->level = level;
279
268
#endif /* UNIV_SYNC_DEBUG */
280
269
 
281
 
        ut_d(lock->magic_n = RW_LOCK_MAGIC_N);
 
270
        lock->magic_n = RW_LOCK_MAGIC_N;
282
271
 
283
272
        lock->cfile_name = cfile_name;
284
273
        lock->cline = (unsigned int) cline;
293
282
 
294
283
        mutex_enter(&rw_lock_list_mutex);
295
284
 
296
 
        ut_ad(UT_LIST_GET_FIRST(rw_lock_list) == NULL
297
 
              || UT_LIST_GET_FIRST(rw_lock_list)->magic_n == RW_LOCK_MAGIC_N);
 
285
        if (UT_LIST_GET_LEN(rw_lock_list) > 0) {
 
286
                ut_a(UT_LIST_GET_FIRST(rw_lock_list)->magic_n
 
287
                     == RW_LOCK_MAGIC_N);
 
288
        }
298
289
 
299
290
        UT_LIST_ADD_FIRST(list, rw_lock_list, lock);
300
291
 
307
298
rw-lock is checked to be in the non-locked state. */
308
299
UNIV_INTERN
309
300
void
310
 
rw_lock_free_func(
311
 
/*==============*/
 
301
rw_lock_free(
 
302
/*=========*/
312
303
        rw_lock_t*      lock)   /*!< in: rw-lock */
313
304
{
314
305
        ut_ad(rw_lock_validate(lock));
315
306
        ut_a(lock->lock_word == X_LOCK_DECR);
316
307
 
 
308
        lock->magic_n = 0;
 
309
 
317
310
#ifndef INNODB_RW_LOCKS_USE_ATOMICS
318
311
        mutex_free(rw_lock_get_mutex(lock));
319
312
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
323
316
 
324
317
        os_event_free(lock->wait_ex_event);
325
318
 
326
 
        ut_ad(UT_LIST_GET_PREV(list, lock) == NULL
327
 
              || UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N);
328
 
        ut_ad(UT_LIST_GET_NEXT(list, lock) == NULL
329
 
              || UT_LIST_GET_NEXT(list, lock)->magic_n == RW_LOCK_MAGIC_N);
 
319
        if (UT_LIST_GET_PREV(list, lock)) {
 
320
                ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N);
 
321
        }
 
322
        if (UT_LIST_GET_NEXT(list, lock)) {
 
323
                ut_a(UT_LIST_GET_NEXT(list, lock)->magic_n == RW_LOCK_MAGIC_N);
 
324
        }
330
325
 
331
326
        UT_LIST_REMOVE(list, rw_lock_list, lock);
332
327
 
333
328
        mutex_exit(&rw_lock_list_mutex);
334
 
 
335
 
        ut_d(lock->magic_n = 0);
336
329
}
337
330
 
338
331
#ifdef UNIV_DEBUG
346
339
/*=============*/
347
340
        rw_lock_t*      lock)   /*!< in: rw-lock */
348
341
{
349
 
        ulint   waiters;
350
 
        lint    lock_word;
351
 
 
352
342
        ut_a(lock);
353
343
 
354
 
        waiters = rw_lock_get_waiters(lock);
355
 
        lock_word = lock->lock_word;
 
344
        ulint waiters = rw_lock_get_waiters(lock);
 
345
        lint lock_word = lock->lock_word;
356
346
 
357
 
        ut_ad(lock->magic_n == RW_LOCK_MAGIC_N);
 
347
        ut_a(lock->magic_n == RW_LOCK_MAGIC_N);
358
348
        ut_a(waiters == 0 || waiters == 1);
359
349
        ut_a(lock_word > -X_LOCK_DECR ||(-lock_word) % X_LOCK_DECR == 0);
360
350
 
617
607
{
618
608
        ulint   index;  /*!< index of the reserved wait cell */
619
609
        ulint   i;      /*!< spin round count */
620
 
        ibool   spinning = FALSE;
 
610
        ibool   spinning = FALSE;
621
611
 
622
612
        ut_ad(rw_lock_validate(lock));
623
613
 
1002
992
 
1003
993
        rwt       = info->lock_type;
1004
994
 
1005
 
        fprintf(stderr, "Locked: thread %lu file %s line %lu  ",
 
995
        fprintf(stderr, "Locked: thread %ld file %s line %ld  ",
1006
996
                (ulong) os_thread_pf(info->thread_id), info->file_name,
1007
997
                (ulong) info->line);
1008
998
        if (rwt == RW_LOCK_SHARED) {