summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gorrod <alexg@wiredtiger.com>2014-12-22 10:54:43 +1100
committerAlex Gorrod <alexg@wiredtiger.com>2014-12-22 10:54:43 +1100
commit42a5beaba747023f0b6b96651a83ab4b4543d520 (patch)
tree2b5d2286d2e746b2bd0cdb675a5b574c7fae689a
parente913b0811114d65b543cd78824e809eb487fd330 (diff)
parent7349568e154f116ebf4845baf2140b1afd942a7b (diff)
downloadmongo-42a5beaba747023f0b6b96651a83ab4b4543d520.tar.gz
Merge branch 'develop' into evict-trickle
-rw-r--r--build_win/filelist.win1
-rw-r--r--dist/filelist1
-rw-r--r--dist/s_string.ok2
-rwxr-xr-xdist/s_win5
-rw-r--r--src/conn/conn_api.c33
-rw-r--r--src/conn/conn_dhandle.c2
-rw-r--r--src/include/dhandle.h13
-rw-r--r--src/include/extern.h1
-rw-r--r--src/lsm/lsm_worker.c6
-rw-r--r--src/os_posix/os_getenv.c26
-rw-r--r--src/os_win/os_getenv.c35
-rw-r--r--src/schema/schema_drop.c4
-rw-r--r--test/suite/test_schema03.py16
13 files changed, 111 insertions, 34 deletions
diff --git a/build_win/filelist.win b/build_win/filelist.win
index c7903c0a161..78ddcb14a59 100644
--- a/build_win/filelist.win
+++ b/build_win/filelist.win
@@ -113,6 +113,7 @@ src/os_win/os_filesize.c
src/os_win/os_flock.c
src/os_win/os_fsync.c
src/os_win/os_ftruncate.c
+src/os_win/os_getenv.c
src/os_win/os_map.c
src/os_win/os_mtx_cond.c
src/os_win/os_once.c
diff --git a/dist/filelist b/dist/filelist
index 07469f49311..c2346caf1ea 100644
--- a/dist/filelist
+++ b/dist/filelist
@@ -109,6 +109,7 @@ src/os_posix/os_filesize.c
src/os_posix/os_flock.c
src/os_posix/os_fsync.c
src/os_posix/os_ftruncate.c
+src/os_posix/os_getenv.c
src/os_posix/os_getline.c
src/os_posix/os_getopt.c
src/os_posix/os_map.c
diff --git a/dist/s_string.ok b/dist/s_string.ok
index aa5d65bcc8b..94f3ea6b6a5 100644
--- a/dist/s_string.ok
+++ b/dist/s_string.ok
@@ -138,6 +138,7 @@ GETTIMEOFDAY
GIDs
Gcc
Geoff
+GetEnvironmentVariableA
GetFileAttributesEx
GetFileSizeEx
GetLastError
@@ -639,6 +640,7 @@ func
funcs
gcc
gdb
+getenv
getfiles
getid
getline
diff --git a/dist/s_win b/dist/s_win
index 180fbd33d83..187de91e498 100755
--- a/dist/s_win
+++ b/dist/s_win
@@ -3,6 +3,10 @@
t=__wt.$$
trap 'rm -f $t' 0 1 2 3 13 15
+# Insulate against locale-specific sort order
+LC_ALL=C
+export LC_ALL
+
win_config()
{
f='../build_win/wiredtiger_config.h'
@@ -40,6 +44,7 @@ win_filelist()
-e 's;os_posix/os_flock.c;os_win/os_flock.c;' \
-e 's;os_posix/os_fsync.c;os_win/os_fsync.c;' \
-e 's;os_posix/os_ftruncate.c;os_win/os_ftruncate.c;' \
+ -e 's;os_posix/os_getenv.c;os_win/os_getenv.c;' \
-e 's;os_posix/os_map.c;os_win/os_map.c;' \
-e 's;os_posix/os_mtx_cond.c;os_win/os_mtx_cond.c;' \
-e 's;os_posix/os_once.c;os_win/os_once.c;' \
diff --git a/src/conn/conn_api.c b/src/conn/conn_api.c
index cc88f848861..33e04826644 100644
--- a/src/conn/conn_api.c
+++ b/src/conn/conn_api.c
@@ -1007,15 +1007,17 @@ static int
__conn_config_env(WT_SESSION_IMPL *session, const char *cfg[], WT_ITEM *cbuf)
{
WT_CONFIG_ITEM cval;
+ WT_DECL_RET;
const char *env_config;
size_t len;
- if ((env_config = getenv("WIREDTIGER_CONFIG")) == NULL)
+ ret = __wt_getenv(session, "WIREDTIGER_CONFIG", &env_config);
+ if (ret == WT_NOTFOUND)
return (0);
len = strlen(env_config);
if (len == 0)
return (0);
- WT_RET(__wt_buf_set(session, cbuf, env_config, len + 1));
+ WT_ERR(__wt_buf_set(session, cbuf, env_config, len + 1));
/*
* Security stuff:
@@ -1023,26 +1025,29 @@ __conn_config_env(WT_SESSION_IMPL *session, const char *cfg[], WT_ITEM *cbuf)
* If the "use_environment_priv" configuration string is set, use the
* environment variable if the process has appropriate privileges.
*/
- WT_RET(__wt_config_gets(session, cfg, "use_environment_priv", &cval));
+ WT_ERR(__wt_config_gets(session, cfg, "use_environment_priv", &cval));
if (cval.val == 0 && __wt_has_priv())
- WT_RET_MSG(session, WT_ERROR, "%s",
+ WT_ERR_MSG(session, WT_ERROR, "%s",
"WIREDTIGER_CONFIG environment variable set but process "
"lacks privileges to use that environment variable");
/* Check any version. */
- WT_RET(__conn_config_check_version(session, env_config));
+ WT_ERR(__conn_config_check_version(session, env_config));
/* Upgrade the configuration string. */
- WT_RET(__wt_config_upgrade(session, cbuf));
+ WT_ERR(__wt_config_upgrade(session, cbuf));
/* Check the configuration information. */
- WT_RET(__wt_config_check(session,
+ WT_ERR(__wt_config_check(session,
WT_CONFIG_REF(session, wiredtiger_open), env_config, 0));
/* Append it to the stack. */
- __conn_config_append(cfg, env_config);
+ __conn_config_append(cfg, cbuf->data);
- return (0);
+err: if (env_config != NULL)
+ __wt_free(session, env_config);
+
+ return (ret);
}
/*
@@ -1052,17 +1057,19 @@ __conn_config_env(WT_SESSION_IMPL *session, const char *cfg[], WT_ITEM *cbuf)
static int
__conn_home(WT_SESSION_IMPL *session, const char *home, const char *cfg[])
{
+ WT_DECL_RET;
WT_CONFIG_ITEM cval;
/* If the application specifies a home directory, use it. */
if (home != NULL)
goto copy;
+ ret = __wt_getenv(session, "WIREDTIGER_HOME", &S2C(session)->home);
+ if (ret == 0)
+ return (0);
+
/* If there's no WIREDTIGER_HOME environment variable, use ".". */
- if ((home = getenv("WIREDTIGER_HOME")) == NULL || strlen(home) == 0) {
- home = ".";
- goto copy;
- }
+ home = ".";
/*
* Security stuff:
diff --git a/src/conn/conn_dhandle.c b/src/conn/conn_dhandle.c
index 6d331f691fd..184fac26d7c 100644
--- a/src/conn/conn_dhandle.c
+++ b/src/conn/conn_dhandle.c
@@ -716,7 +716,7 @@ __wt_conn_dhandle_discard_single(WT_SESSION_IMPL *session, int final)
__wt_spin_destroy(session, &dhandle->close_lock);
__wt_overwrite_and_free(session, dhandle);
- WT_CLEAR_BTREE_IN_SESSION(session);
+ session->dhandle = NULL;
}
return (ret);
diff --git a/src/include/dhandle.h b/src/include/dhandle.h
index 8cd7c9ba90b..1a6839b11fe 100644
--- a/src/include/dhandle.h
+++ b/src/include/dhandle.h
@@ -5,19 +5,6 @@
* See the file LICENSE for redistribution information.
*/
-/*
- * XXX
- * The server threads use their own WT_SESSION_IMPL handles because they may
- * want to block (for example, the eviction server calls reconciliation, and
- * some of the reconciliation diagnostic code reads pages), and the user's
- * session handle is already blocking on a server thread. The problem is the
- * server thread needs to reference the correct btree handle, and that's
- * hanging off the application's thread of control. For now, I'm just making
- * it obvious where that's getting done.
- */
-#define WT_SET_BTREE_IN_SESSION(s, b) ((s)->dhandle = b->dhandle)
-#define WT_CLEAR_BTREE_IN_SESSION(s) ((s)->dhandle = NULL)
-
#define WT_WITH_DHANDLE(s, d, e) do { \
WT_DATA_HANDLE *__saved_dhandle = (s)->dhandle; \
(s)->dhandle = (d); \
diff --git a/src/include/extern.h b/src/include/extern.h
index bb7caa991d6..99323a0b126 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -442,6 +442,7 @@ extern int __wt_directory_sync(WT_SESSION_IMPL *session, char *path);
extern int __wt_fsync(WT_SESSION_IMPL *session, WT_FH *fh);
extern int __wt_fsync_async(WT_SESSION_IMPL *session, WT_FH *fh);
extern int __wt_ftruncate(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t len);
+extern int __wt_getenv(WT_SESSION_IMPL *session, const char *variable, const char **env);
extern int __wt_getline(WT_SESSION_IMPL *session, WT_ITEM *buf, FILE *fp);
extern int __wt_getopt( const char *progname, int nargc, char *const *nargv, const char *ostr);
extern int __wt_mmap(WT_SESSION_IMPL *session, WT_FH *fh, void *mapp, size_t *lenp, void **mappingcookie);
diff --git a/src/lsm/lsm_worker.c b/src/lsm/lsm_worker.c
index 955dd09193b..703453305ba 100644
--- a/src/lsm/lsm_worker.c
+++ b/src/lsm/lsm_worker.c
@@ -141,8 +141,10 @@ __lsm_worker(void *arg)
ret = 0;
} else if (ret == EBUSY)
ret = 0;
- /* Clear any state */
- WT_CLEAR_BTREE_IN_SESSION(session);
+
+ /* Paranoia: clear session state. */
+ session->dhandle = NULL;
+
__wt_lsm_manager_free_work_unit(session, entry);
entry = NULL;
progress = 1;
diff --git a/src/os_posix/os_getenv.c b/src/os_posix/os_getenv.c
new file mode 100644
index 00000000000..83cf8a75770
--- /dev/null
+++ b/src/os_posix/os_getenv.c
@@ -0,0 +1,26 @@
+/*-
+ * Copyright (c) 2008-2014 WiredTiger, Inc.
+ * All rights reserved.
+ *
+ * See the file LICENSE for redistribution information.
+ */
+
+#include "wt_internal.h"
+
+/*
+ * __wt_getenv --
+ * Get a non-null environment variable
+ */
+int
+__wt_getenv(WT_SESSION_IMPL *session, const char *variable, const char **env)
+{
+ const char *temp;
+
+ *env = NULL;
+
+ if (((temp = getenv(variable)) != NULL) && strlen(temp) > 0) {
+ return (__wt_strdup(session, temp, env));
+ }
+
+ return (WT_NOTFOUND);
+}
diff --git a/src/os_win/os_getenv.c b/src/os_win/os_getenv.c
new file mode 100644
index 00000000000..31505266d76
--- /dev/null
+++ b/src/os_win/os_getenv.c
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2008-2014 WiredTiger, Inc.
+ * All rights reserved.
+ *
+ * See the file LICENSE for redistribution information.
+ */
+
+#include "wt_internal.h"
+
+/*
+ * __wt_getenv --
+ * Get a non-null environment variable
+ */
+int
+__wt_getenv(WT_SESSION_IMPL *session, const char *variable, const char **env)
+{
+ WT_DECL_RET;
+ DWORD size;
+
+ *env = NULL;
+
+ size = GetEnvironmentVariableA(variable, NULL, 0);
+ if (size <= 1)
+ return (WT_NOTFOUND);
+
+ WT_RET(__wt_calloc(session, 1, size, env));
+
+ ret = GetEnvironmentVariableA(variable, *env, size);
+ /* We expect the number of bytes not including null terminator */
+ if ((ret + 1) != size)
+ WT_RET_MSG(session, __wt_errno(),
+ "GetEnvironmentVariableA failed: %s", variable);
+
+ return (0);
+}
diff --git a/src/schema/schema_drop.c b/src/schema/schema_drop.c
index ca09d25a495..9a74b26ffec 100644
--- a/src/schema/schema_drop.c
+++ b/src/schema/schema_drop.c
@@ -165,8 +165,8 @@ __wt_schema_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[])
WT_RET(__wt_meta_track_on(session));
- /* Be careful to ignore any btree handle in our caller. */
- WT_CLEAR_BTREE_IN_SESSION(session);
+ /* Paranoia: clear any handle from our caller. */
+ session->dhandle = NULL;
if (WT_PREFIX_MATCH(uri, "colgroup:"))
ret = __drop_colgroup(session, uri, force, cfg);
diff --git a/test/suite/test_schema03.py b/test/suite/test_schema03.py
index 48d8e6b2986..e650d8b6964 100644
--- a/test/suite/test_schema03.py
+++ b/test/suite/test_schema03.py
@@ -25,10 +25,17 @@
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
-import resource
+import os
import suite_random
import wiredtiger, wtscenario, wttest
+try:
+ # Windows does not getrlimit/setrlimit so we must catch the resource
+ # module load
+ import resource
+except:
+ None
+
# test_schema03.py
# Bigger, more 'randomly generated' schemas and data.
# This test is complex. If it fails, rerun with modified values for
@@ -190,7 +197,7 @@ class test_schema03(wttest.WiredTigerTestCase):
created in various orders as much as the API allows. On some runs
the connection will be closed and reopened at a particular point
to test that the schemas (and data) are saved and read correctly.
-
+
The test is run multiple times, using scenarios.
The test always follows these steps:
- table: create tables
@@ -277,6 +284,9 @@ class test_schema03(wttest.WiredTigerTestCase):
# This test requires a large number of open files.
# Increase our resource limits before we start
def setUp(self):
+ if os.name == "nt":
+ self.skipTest('Unix specific test skipped on Windows')
+
self.origFileLimit = resource.getrlimit(resource.RLIMIT_NOFILE)
newlimit = (self.OPEN_FILE_LIMIT, self.origFileLimit[1])
if newlimit[0] > newlimit[1]:
@@ -289,7 +299,7 @@ class test_schema03(wttest.WiredTigerTestCase):
'create,cache_size=100m,session_max=1000')
self.pr(`conn`)
return conn
-
+
def tearDown(self):
super(test_schema03, self).tearDown()
resource.setrlimit(resource.RLIMIT_NOFILE, self.origFileLimit)