diff options
author | Alex Gorrod <alexg@wiredtiger.com> | 2016-04-08 12:51:19 +1000 |
---|---|---|
committer | Alex Gorrod <alexg@wiredtiger.com> | 2016-04-08 12:51:19 +1000 |
commit | e0fc972c47872ad517cd44c9c517eba01242bf8e (patch) | |
tree | d3dfca5ff5a4f66f0ec2a144ee46277ac3a91cf4 | |
parent | 5535876ce00b27135a728dee4b5171ab0732481b (diff) | |
download | mongo-e0fc972c47872ad517cd44c9c517eba01242bf8e.tar.gz |
SERVER-23588 Stop using _open_osfhandle on Windows.
It introduced some odd failures on debug MongoDB builds. Switch
to using fopen instead.
-rw-r--r-- | src/os_win/os_fs.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/os_win/os_fs.c b/src/os_win/os_fs.c index 462773cb9fb..95c0ea40ce6 100644 --- a/src/os_win/os_fs.c +++ b/src/os_win/os_fs.c @@ -217,20 +217,20 @@ __win_handle_close(WT_SESSION_IMPL *session, WT_FH *fh) { WT_DECL_RET; - if (fh->fp == NULL) { + if (fh->filehandle != INVALID_HANDLE_VALUE) { /* * We don't open Windows system handles when opening directories * for flushing, as it is not necessary (or possible) to flush * a directory on Windows. Confirm the file handle is set before * attempting to close it. */ - if (fh->filehandle != INVALID_HANDLE_VALUE && - CloseHandle(fh->filehandle) == 0) { + if (CloseHandle(fh->filehandle) == 0) { ret = __wt_getlasterror(); __wt_err(session, ret, "%s: handle-close: CloseHandle", fh->name); } - } else { + } + if (fh->fp != NULL) { /* If the stream was opened for writing, flush the file. */ if (F_ISSET(fh, WT_FH_FLUSH_ON_CLOSE) && fflush(fh->fp) != 0) { ret = __wt_errno(); @@ -506,7 +506,7 @@ __win_handle_open(WT_SESSION_IMPL *session, HANDLE filehandle, filehandle_secondary; WT_CONNECTION_IMPL *conn; WT_DECL_RET; - int desired_access, f, fd; + int desired_access, f; bool direct_io; const char *stream_mode; @@ -628,12 +628,10 @@ __win_handle_open(WT_SESSION_IMPL *session, break; } if (stream_mode != NULL) { - if ((fd = _open_osfhandle((intptr_t)filehandle, f)) == -1) + if ((fh->fp = fopen(name, stream_mode)) == NULL) WT_ERR_MSG(session, __wt_errno(), - "%s: handle-open: _open_osfhandle", name); - if ((fh->fp = fdopen(fd, stream_mode)) == NULL) - WT_ERR_MSG(session, __wt_errno(), - "%s: handle-open: fdopen", name); + "%s: handle-open: fopen", name); + if (LF_ISSET(WT_STREAM_LINE_BUFFER)) __wt_stream_set_line_buffer(fh->fp); } |