From da0b6d611fcbe15e18fd888e9bf3578855caca09 Mon Sep 17 00:00:00 2001
From: Vasil Dimov <vasil.dimov@oracle.com>
Date: Mon, 31 May 2010 19:35:40 +0300
Subject: [PATCH] Merge a change from mysql-trunk-innodb:

  ------------------------------------------------------------
  revno: 3127
  revision-id: vasil.dimov@oracle.com-20100531152341-x2d4hma644icamh1
  parent: vasil.dimov@oracle.com-20100531105923-kpjwl4rbgfpfj13c
  committer: Vasil Dimov <vasil.dimov@oracle.com>
  branch nick: mysql-trunk-innodb
  timestamp: Mon 2010-05-31 18:23:41 +0300
  message:
    Fix Bug #53947 InnoDB: Assertion failure in thread 4224 in file .\sync\sync0sync.c line 324

    Destroy the rw-lock object before freeing the memory it is occupying.
    If we do not do this, then the mutex that is contained in the rw-lock
    object btr_search_latch_temp->mutex gets "freed" and subsequently
    mutex_free() from sync_close() hits a mutex whose memory has been
    freed and crashes.

    Approved by:	Heikki (via IRC)
    Discussed with:	Calvin
---
 storage/innodb_plugin/btr/btr0sea.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/storage/innodb_plugin/btr/btr0sea.c b/storage/innodb_plugin/btr/btr0sea.c
index ef7afeb1039..c91afa31bf0 100644
--- a/storage/innodb_plugin/btr/btr0sea.c
+++ b/storage/innodb_plugin/btr/btr0sea.c
@@ -182,6 +182,7 @@ void
 btr_search_sys_free(void)
 /*=====================*/
 {
+	rw_lock_free(&btr_search_latch);
 	mem_free(btr_search_latch_temp);
 	btr_search_latch_temp = NULL;
 	mem_heap_free(btr_search_sys->hash_index->heap);