コード例 #1
0
ファイル: sync0rw.c プロジェクト: A-eolus/mysql
/******************************************************************//**
Checks that the rw-lock has been initialized and that there are no
simultaneous shared and exclusive locks.
@return	TRUE */
UNIV_INTERN
ibool
rw_lock_validate(
/*=============*/
	rw_lock_t*	lock)	/*!< in: rw-lock */
{
	ulint	waiters;
	lint	lock_word;

	ut_a(lock);

	waiters = rw_lock_get_waiters(lock);
	lock_word = lock->lock_word;

	ut_ad(lock->magic_n == RW_LOCK_MAGIC_N);
	ut_a(waiters == 0 || waiters == 1);
	ut_a(lock_word > -X_LOCK_DECR ||(-lock_word) % X_LOCK_DECR == 0);

	return(TRUE);
}
コード例 #2
0
ファイル: sync0rw.c プロジェクト: zhangsong246/mysql-3.23.49
void
rw_lock_free(
    /*=========*/
    rw_lock_t*	lock)	/* in: rw-lock */
{
    ut_ad(rw_lock_validate(lock));
    ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED);
    ut_a(rw_lock_get_waiters(lock) == 0);
    ut_a(rw_lock_get_reader_count(lock) == 0);

    lock->magic_n = 0;

    mutex_free(rw_lock_get_mutex(lock));

    mutex_enter(&rw_lock_list_mutex);

    UT_LIST_REMOVE(list, rw_lock_list, lock);

    mutex_exit(&rw_lock_list_mutex);
}
コード例 #3
0
ファイル: sync0rw.c プロジェクト: A-eolus/mysql
/***************************************************************//**
Prints debug info of an rw-lock. */
UNIV_INTERN
void
rw_lock_print(
/*==========*/
	rw_lock_t*	lock)	/*!< in: rw-lock */
{
	rw_lock_debug_t* info;

	fprintf(stderr,
		"-------------\n"
		"RW-LATCH INFO\n"
		"RW-LATCH: %p ", (void*) lock);

#ifndef INNODB_RW_LOCKS_USE_ATOMICS
	/* We used to acquire lock->mutex here, but it would cause a
	recursive call to sync_thread_add_level() if UNIV_SYNC_DEBUG
	is defined.  Since this function is only invoked from
	sync_thread_levels_g(), let us choose the smaller evil:
	performing dirty reads instead of causing bogus deadlocks or
	assertion failures. */
#endif
	if (lock->lock_word != X_LOCK_DECR) {

		if (rw_lock_get_waiters(lock)) {
			fputs(" Waiters for the lock exist\n", stderr);
		} else {
			putc('\n', stderr);
		}

		rw_lock_debug_mutex_enter();
		info = UT_LIST_GET_FIRST(lock->debug_list);
		while (info != NULL) {
			rw_lock_debug_print(stderr, info);
			info = UT_LIST_GET_NEXT(list, info);
		}
		rw_lock_debug_mutex_exit();
	}
}