diff options
author | Keith Bostic <keith.bostic@mongodb.com> | 2015-01-26 13:55:43 -0500 |
---|---|---|
committer | Keith Bostic <keith.bostic@mongodb.com> | 2015-01-26 13:55:43 -0500 |
commit | 2e3f76470b69f25427e8b1b1bda5cd3be89556ec (patch) | |
tree | 7f6b13c45e289456f9c41f94263b401c0e88bf53 | |
parent | 34fde1b48308f194d9fc9845a3ca9f3ea358b001 (diff) | |
parent | 208f0ed898e92e3f0c043b7734bfe0c4885ef227 (diff) | |
download | mongo-2e3f76470b69f25427e8b1b1bda5cd3be89556ec.tar.gz |
Merge pull request #1595 from markbenvenuto/win_handle_leak
Close Thread Handle after thread join on Windows
-rw-r--r-- | src/os_win/os_map.c | 5 | ||||
-rw-r--r-- | src/os_win/os_open.c | 4 | ||||
-rw-r--r-- | src/os_win/os_thread.c | 15 |
3 files changed, 18 insertions, 6 deletions
diff --git a/src/os_win/os_map.c b/src/os_win/os_map.c index 5c78f371889..3c4edb59ea8 100644 --- a/src/os_win/os_map.c +++ b/src/os_win/os_map.c @@ -99,7 +99,10 @@ __wt_munmap(WT_SESSION_IMPL *session, WT_FH *fh, void *map, size_t len, fh->name, len); } - CloseHandle(*mappingcookie); + if (CloseHandle(*mappingcookie) == 0) { + WT_RET_MSG(session, __wt_errno(), + "CloseHandle: MapViewOfFile: %s", fh->name); + } *mappingcookie = 0; diff --git a/src/os_win/os_open.c b/src/os_win/os_open.c index 387c7d2597b..bfcfb13fc3b 100644 --- a/src/os_win/os_open.c +++ b/src/os_win/os_open.c @@ -214,13 +214,13 @@ __wt_close(WT_SESSION_IMPL *session, WT_FH *fh) * windows since it is not possible to sync a directory */ if (fh->filehandle != INVALID_HANDLE_VALUE && - !CloseHandle(fh->filehandle) != 0) { + CloseHandle(fh->filehandle) == 0) { ret = __wt_errno(); __wt_err(session, ret, "CloseHandle: %s", fh->name); } if (fh->filehandle_secondary != INVALID_HANDLE_VALUE && - !CloseHandle(fh->filehandle_secondary) != 0) { + CloseHandle(fh->filehandle_secondary) == 0) { ret = __wt_errno(); __wt_err(session, ret, "CloseHandle: secondary: %s", fh->name); } diff --git a/src/os_win/os_thread.c b/src/os_win/os_thread.c index 3ecfe2796d5..05f7dc15914 100644 --- a/src/os_win/os_thread.c +++ b/src/os_win/os_thread.c @@ -33,10 +33,19 @@ __wt_thread_join(WT_SESSION_IMPL *session, wt_thread_t tid) { WT_DECL_RET; - if ((ret = WaitForSingleObject(tid, INFINITE)) == WAIT_OBJECT_0) - return (0); + if ((ret = WaitForSingleObject(tid, INFINITE)) != WAIT_OBJECT_0) + /* + * If we fail to wait, we will leak handles so do not continue + */ + WT_PANIC_RET(session, ret == WAIT_FAILED ? __wt_errno() : ret, + "Wait for thread join failed"); + + if (CloseHandle(tid) == 0) { + WT_RET_MSG(session, __wt_errno(), + "CloseHandle: thread join"); + } - WT_RET_MSG(session, ret, "WaitForSingleObject"); + return (0); } /* |