summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2016-04-08 15:02:22 +1000
committerMichael Cahill <michael.cahill@mongodb.com>2016-04-08 15:02:22 +1000
commit5206656dfbb725a031be35203fc05f3f3beedc6f (patch)
treed3dfca5ff5a4f66f0ec2a144ee46277ac3a91cf4
parent5535876ce00b27135a728dee4b5171ab0732481b (diff)
parente0fc972c47872ad517cd44c9c517eba01242bf8e (diff)
downloadmongo-5206656dfbb725a031be35203fc05f3f3beedc6f.tar.gz
Merge pull request #2638 from wiredtiger/server-23588-win-fopen
SERVER-23588 Stop using _open_osfhandle on Windows.
-rw-r--r--src/os_win/os_fs.c18
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);
}