diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog
index 3b1f202c8ac520a3bfa09da360955f3b124e9ec7..d193dcd321c6582ce9bed0cd52c5b4667f4deee0 100644
--- a/storage/innodb_plugin/ChangeLog
+++ b/storage/innodb_plugin/ChangeLog
@@ -1,3 +1,7 @@
+2010-10-14	The InnoDB Team
+	* srv/srv0start.c
+	Fix Bug #57397 io_handler_thread() will never cleanup
+
 2010-10-11	The InnoDB Team
 	* row/row0sel.c
 	Fix Bug #57345 btr_pcur_store_position abort for load with
diff --git a/storage/innodb_plugin/srv/srv0start.c b/storage/innodb_plugin/srv/srv0start.c
index ba9fc831b39d42960ad564a5eb0b4919a9069de2..2d33959601334a4d5fbfafe51fea1bc614a590a3 100644
--- a/storage/innodb_plugin/srv/srv0start.c
+++ b/storage/innodb_plugin/srv/srv0start.c
@@ -471,7 +471,7 @@ io_handler_thread(
 	fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment,
 		os_thread_pf(os_thread_get_curr_id()));
 #endif
-	for (i = 0;; i++) {
+	while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS) {
 		fil_aio_wait(segment);
 
 		mutex_enter(&ios_mutex);
@@ -479,8 +479,6 @@ io_handler_thread(
 		mutex_exit(&ios_mutex);
 	}
 
-	thr_local_free(os_thread_get_curr_id());
-
 	/* We count the number of threads in os_thread_exit(). A created
 	thread should always use that to exit and not use return() to exit.
 	The thread actually never comes here because it is exited in an
@@ -1894,7 +1892,7 @@ innobase_shutdown_for_mysql(void)
 #ifdef __NETWARE__
 	if (!panic_shutdown)
 #endif
-		logs_empty_and_mark_files_at_shutdown();
+	logs_empty_and_mark_files_at_shutdown();
 
 	if (srv_conc_n_threads != 0) {
 		fprintf(stderr,