summaryrefslogtreecommitdiff
path: root/src/os_win/os_errno.c
diff options
context:
space:
mode:
authorAlex Gorrod <alexander.gorrod@mongodb.com>2016-04-01 15:50:16 +1100
committerAlex Gorrod <alexander.gorrod@mongodb.com>2016-04-01 15:50:16 +1100
commita2dec6e48b269db78f94260a5f6f174404affa4a (patch)
tree4ba83c2204f623e36fb6d506904fb782f99ffff5 /src/os_win/os_errno.c
parent385b126a7d517afd7eb711b04d71bb3b5a03c917 (diff)
parent357bf28ba3fc1d5902b429a9e634015187f648ed (diff)
downloadmongo-a2dec6e48b269db78f94260a5f6f174404affa4a.tar.gz
Merge pull request #2603 from wiredtiger/wt-2330
WT-2330: in-memory configurations should not create on-disk collection files
Diffstat (limited to 'src/os_win/os_errno.c')
-rw-r--r--src/os_win/os_errno.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/os_win/os_errno.c b/src/os_win/os_errno.c
index 590fcdc9d44..f3fffd5ef42 100644
--- a/src/os_win/os_errno.c
+++ b/src/os_win/os_errno.c
@@ -46,13 +46,13 @@ __wt_map_windows_error_to_error(DWORD winerr)
* of failures.
*/
int
-__wt_map_error_rdonly(int winerr)
+__wt_map_error_rdonly(int error)
{
- if (winerr == ERROR_FILE_NOT_FOUND)
+ if (error == ERROR_FILE_NOT_FOUND)
return (WT_NOTFOUND);
- else if (winerr == ERROR_ACCESS_DENIED)
+ else if (error == ERROR_ACCESS_DENIED)
return (WT_PERM_DENIED);
- return (winerr);
+ return (error);
}
/*
@@ -63,14 +63,33 @@ int
__wt_errno(void)
{
/*
+ * Check for 0:
+ * It's easy to introduce a problem by calling the wrong error function,
+ * for example, this function when the MSVC function set the C runtime
+ * error value. Handle gracefully and always return an error.
+ */
+ return (errno == 0 ? WT_ERROR : errno);
+}
+
+/*
+ * __wt_getlasterror --
+ * Return GetLastError, or WT_ERROR if error not set.
+ */
+int
+__wt_getlasterror(void)
+{
+ /*
* Called when we know an error occurred, and we want the system
- * error code, but there's some chance it's not set.
+ * error code.
*/
DWORD err = GetLastError();
- /* GetLastError should only be called if we hit an actual error */
- WT_ASSERT(NULL, err != ERROR_SUCCESS);
-
+ /*
+ * Check for ERROR_SUCCESS:
+ * It's easy to introduce a problem by calling the wrong error function,
+ * for example, this function when the MSVC function set the C runtime
+ * error value. Handle gracefully and always return an error.
+ */
return (err == ERROR_SUCCESS ?
WT_ERROR : __wt_map_windows_error_to_error(err));
}