summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2016-09-13 18:23:14 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2016-09-13 18:23:14 +0000
commit7c6037ceda560a8701f19aa635e176aae6d3ccee (patch)
tree3db57ea26cda94941882b822d3a7bc1bd64d84a1
parentbc526a55742af9894d5a6440868e9011485d9029 (diff)
downloadmariadb-git-7c6037ceda560a8701f19aa635e176aae6d3ccee.tar.gz
Windows : CloseHandle() returned by CreateThread().
Don't wait until os_thread_exit to close it. Remove code from innodb_shutdown to close handles on Windows.
-rw-r--r--storage/innobase/include/os0thread.h2
-rw-r--r--storage/innobase/os/os0thread.cc29
-rw-r--r--storage/innobase/srv/srv0start.cc28
3 files changed, 4 insertions, 55 deletions
diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h
index 0be2fa89d06..9ba35b6f359 100644
--- a/storage/innobase/include/os0thread.h
+++ b/storage/innobase/include/os0thread.h
@@ -42,7 +42,7 @@ can wait inside InnoDB */
#define OS_THREAD_PRIORITY_ABOVE_NORMAL 3
#ifdef _WIN32
-typedef void* os_thread_t;
+typedef DWORD os_thread_t;
typedef DWORD os_thread_id_t; /*!< In Windows the thread id
is an unsigned long int */
extern "C" {
diff --git a/storage/innobase/os/os0thread.cc b/storage/innobase/os/os0thread.cc
index 811bd87cef7..2d9abaa6c52 100644
--- a/storage/innobase/os/os0thread.cc
+++ b/storage/innobase/os/os0thread.cc
@@ -45,16 +45,6 @@ SysMutex thread_mutex;
/** Number of threads active. */
ulint os_thread_count;
-#ifdef _WIN32
-typedef std::map<
- DWORD,
- HANDLE,
- std::less<DWORD>,
- ut_allocator<std::pair<const DWORD, HANDLE> > > WinThreadMap;
-/** This STL map remembers the initial handle returned by CreateThread
-so that it can be closed when the thread exits. */
-static WinThreadMap win_thread_map;
-#endif /* _WIN32 */
/***************************************************************//**
Compares two thread ids for equality.
@@ -145,22 +135,15 @@ os_thread_create_func(
ib::fatal() << "CreateThread returned " << GetLastError();
}
- mutex_enter(&thread_mutex);
-
- std::pair<WinThreadMap::iterator, bool> ret;
-
- ret = win_thread_map.insert(
- std::pair<DWORD, HANDLE>(new_thread_id, handle));
+ CloseHandle(handle);
- ut_ad((*ret.first).first == new_thread_id);
- ut_ad((*ret.first).second == handle);
- ut_a(ret.second == true); /* true means thread_id was new */
+ mutex_enter(&thread_mutex);
os_thread_count++;
mutex_exit(&thread_mutex);
- return((os_thread_t)handle);
+ return((os_thread_t)new_thread_id);
#else /* _WIN32 else */
pthread_attr_t attr;
@@ -208,12 +191,6 @@ os_thread_exit()
os_thread_count--;
#ifdef _WIN32
- DWORD win_thread_id = GetCurrentThreadId();
- HANDLE handle = win_thread_map[win_thread_id];
- CloseHandle(handle);
- size_t ret = win_thread_map.erase(win_thread_id);
- ut_a(ret == 1);
-
mutex_exit(&thread_mutex);
ExitThread(0);
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 7417dee4fc5..baf9c0183c3 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -2857,34 +2857,6 @@ innobase_shutdown_for_mysql(void)
/* Cleanup data for datafile scrubbing */
btr_scrub_cleanup();
-#ifdef __WIN__
- /* MDEV-361: ha_innodb.dll leaks handles on Windows
- MDEV-7403: should not pass recv_writer_thread_handle to
- CloseHandle().
-
- On Windows we should call CloseHandle() for all
- open thread handles. */
- if (os_thread_count == 0) {
- for (int i = 0; i < SRV_MAX_N_IO_THREADS + 6 + 32; ++i) {
- if (thread_started[i]) {
- CloseHandle(thread_handles[i]);
- }
- }
-
- if (buf_flush_page_cleaner_thread_started) {
- CloseHandle(buf_flush_page_cleaner_thread_handle);
- }
-
- if (buf_dump_thread_started) {
- CloseHandle(buf_dump_thread_handle);
- }
-
- if (dict_stats_thread_started) {
- CloseHandle(dict_stats_thread_handle);
- }
- }
-#endif /* __WIN __ */
-
/* This must be disabled before closing the buffer pool
and closing the data dictionary. */
btr_search_disable(true);