summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2016-04-01 08:18:11 -0400
committerKeith Bostic <keith@wiredtiger.com>2016-04-01 08:18:11 -0400
commit39edc9f66220bab5a8c5e8f0ae6f26979605cd39 (patch)
treeace7a6e92b2f5fd5aa6a11b7ecfd2aa314d23218
parent9b3d1f470e9623364d3172a70c542fb9f3b60d11 (diff)
downloadmongo-39edc9f66220bab5a8c5e8f0ae6f26979605cd39.tar.gz
WT-2525: in-memory configurations: miscellaneous cleanups
Coverity 1353723: don't provide a special-case locking path for in-memory configuration file size queries. It's complicated and invites future bugs, and there's no performance reason we need the magic.
-rw-r--r--src/include/extern.h3
-rw-r--r--src/os_common/os_fhandle.c25
-rw-r--r--src/os_common/os_fs_inmemory.c8
-rw-r--r--src/os_posix/os_fs.c6
-rw-r--r--src/os_win/os_fs.c6
5 files changed, 16 insertions, 32 deletions
diff --git a/src/include/extern.h b/src/include/extern.h
index d4e67b2f313..292bcfb1c7c 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -713,7 +713,7 @@ extern int __wt_txn_named_snapshot_config(WT_SESSION_IMPL *session, const char *
extern int __wt_txn_named_snapshot_destroy(WT_SESSION_IMPL *session);
extern int __wt_txn_recover(WT_SESSION_IMPL *session);
extern bool __wt_absolute_path(const char *path);
-extern bool __wt_handle_search(WT_SESSION_IMPL *session, const char *name, bool increment_ref, bool unlock, WT_FH *newfh, WT_FH **fhp);
+extern bool __wt_handle_search(WT_SESSION_IMPL *session, const char *name, bool increment_ref, WT_FH *newfh, WT_FH **fhp);
extern bool __wt_has_priv(void);
extern const char *__wt_path_separator(void);
extern const char *__wt_strerror(WT_SESSION_IMPL *session, int error, char *errbuf, size_t errlen);
@@ -773,7 +773,6 @@ extern int __wt_win_map_unmap(WT_SESSION_IMPL *session, WT_FH *fh, void *map, si
extern uint64_t __wt_strtouq(const char *nptr, char **endptr, int base);
extern void __wt_abort(WT_SESSION_IMPL *session) WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
extern void __wt_free_int(WT_SESSION_IMPL *session, const void *p_arg);
-extern void __wt_handle_search_unlock(WT_SESSION_IMPL *session);
extern void __wt_posix_handle_allocate_configure(WT_SESSION_IMPL *session, WT_FH *fh);
extern void __wt_sleep(uint64_t seconds, uint64_t micro_seconds);
extern void __wt_stream_set_line_buffer(FILE *fp);
diff --git a/src/os_common/os_fhandle.c b/src/os_common/os_fhandle.c
index 749617b928a..b16b2e24bfa 100644
--- a/src/os_common/os_fhandle.c
+++ b/src/os_common/os_fhandle.c
@@ -13,8 +13,8 @@
* Search for a matching handle.
*/
bool
-__wt_handle_search(WT_SESSION_IMPL *session, const char *name,
- bool increment_ref, bool unlock, WT_FH *newfh, WT_FH **fhp)
+__wt_handle_search(WT_SESSION_IMPL *session,
+ const char *name, bool increment_ref, WT_FH *newfh, WT_FH **fhp)
{
WT_CONNECTION_IMPL *conn;
WT_FH *fh;
@@ -58,27 +58,12 @@ __wt_handle_search(WT_SESSION_IMPL *session, const char *name,
*fhp = newfh;
}
- /*
- * Our caller may be operating on the handle itself, optionally leave
- * the list locked.
- */
- if (unlock)
- __wt_spin_unlock(session, &conn->fh_lock);
+ __wt_spin_unlock(session, &conn->fh_lock);
return (found);
}
/*
- * __wt_handle_search_unlock --
- * Release handle lock.
- */
-void
-__wt_handle_search_unlock(WT_SESSION_IMPL *session)
-{
- __wt_spin_unlock(session, &S2C(session)->fh_lock);
-}
-
-/*
* __open_verbose --
* Optionally output a verbose message on handle open.
*/
@@ -179,7 +164,7 @@ __wt_open(WT_SESSION_IMPL *session,
WT_RET(__open_verbose(session, name, file_type, flags));
/* Check if the handle is already open. */
- if (__wt_handle_search(session, name, true, true, NULL, &fh)) {
+ if (__wt_handle_search(session, name, true, NULL, &fh)) {
/*
* XXX
* The in-memory implementation has to reset the file offset
@@ -223,7 +208,7 @@ __wt_open(WT_SESSION_IMPL *session,
* Repeat the check for a match: if there's no match, link our newly
* created handle onto the database's list of files.
*/
- if (__wt_handle_search(session, name, true, true, fh, fhp)) {
+ if (__wt_handle_search(session, name, true, fh, fhp)) {
err: if (open_called)
WT_TRET(fh->fh_close(session, fh));
if (fh != NULL) {
diff --git a/src/os_common/os_fs_inmemory.c b/src/os_common/os_fs_inmemory.c
index e79054e56ed..0d25fcaf7c3 100644
--- a/src/os_common/os_fs_inmemory.c
+++ b/src/os_common/os_fs_inmemory.c
@@ -52,7 +52,7 @@ __im_directory_sync(WT_SESSION_IMPL *session, const char *path)
static int
__im_file_exist(WT_SESSION_IMPL *session, const char *name, bool *existp)
{
- *existp = __wt_handle_search(session, name, false, true, NULL, NULL);
+ *existp = __wt_handle_search(session, name, false, NULL, NULL);
return (0);
}
@@ -66,7 +66,7 @@ __im_file_remove(WT_SESSION_IMPL *session, const char *name)
WT_DECL_RET;
WT_FH *fh;
- if (__wt_handle_search(session, name, true, true, NULL, &fh)) {
+ if (__wt_handle_search(session, name, true, NULL, &fh)) {
WT_ASSERT(session, fh->ref == 1);
/* Force a discard of the handle. */
@@ -150,9 +150,9 @@ __im_file_size(
im = S2C(session)->inmemory;
__wt_spin_lock(session, &im->lock);
- if (__wt_handle_search(session, name, false, false, NULL, &fh)) {
+ if (__wt_handle_search(session, name, true, NULL, &fh)) {
*sizep = (wt_off_t)fh->buf.size;
- __wt_handle_search_unlock(session);
+ ret = __wt_close(session, &fh);
} else
ret = ENOENT;
diff --git a/src/os_posix/os_fs.c b/src/os_posix/os_fs.c
index 68d70594582..7d3049f6c2d 100644
--- a/src/os_posix/os_fs.c
+++ b/src/os_posix/os_fs.c
@@ -164,7 +164,7 @@ __posix_file_remove(WT_SESSION_IMPL *session, const char *name)
char *path;
#ifdef HAVE_DIAGNOSTIC
- if (__wt_handle_search(session, name, false, true, NULL, NULL))
+ if (__wt_handle_search(session, name, false, NULL, NULL))
WT_RET_MSG(session, EINVAL,
"%s: file-remove: file has open handles", name);
#endif
@@ -191,10 +191,10 @@ __posix_file_rename(WT_SESSION_IMPL *session, const char *from, const char *to)
char *from_path, *to_path;
#ifdef HAVE_DIAGNOSTIC
- if (__wt_handle_search(session, from, false, true, NULL, NULL))
+ if (__wt_handle_search(session, from, false, NULL, NULL))
WT_RET_MSG(session, EINVAL,
"%s: file-rename: file has open handles", from);
- if (__wt_handle_search(session, to, false, true, NULL, NULL))
+ if (__wt_handle_search(session, to, false, NULL, NULL))
WT_RET_MSG(session, EINVAL,
"%s: file-rename: file has open handles", to);
#endif
diff --git a/src/os_win/os_fs.c b/src/os_win/os_fs.c
index bf8232419e9..7f2c797dbe4 100644
--- a/src/os_win/os_fs.c
+++ b/src/os_win/os_fs.c
@@ -55,7 +55,7 @@ __win_file_remove(WT_SESSION_IMPL *session, const char *name)
char *path;
#ifdef HAVE_DIAGNOSTIC
- if (__wt_handle_search(session, name, false, true, NULL, NULL))
+ if (__wt_handle_search(session, name, false, NULL, NULL))
WT_RET_MSG(session, EINVAL,
"%s: file-remove: file has open handles", name);
#endif
@@ -83,10 +83,10 @@ __win_file_rename(WT_SESSION_IMPL *session, const char *from, const char *to)
char *from_path, *to_path;
#ifdef HAVE_DIAGNOSTIC
- if (__wt_handle_search(session, from, false, true, NULL, NULL))
+ if (__wt_handle_search(session, from, false, NULL, NULL))
WT_RET_MSG(session, EINVAL,
"%s: file-rename: file has open handles", from);
- if (__wt_handle_search(session, to, false, true, NULL, NULL))
+ if (__wt_handle_search(session, to, false, NULL, NULL))
WT_RET_MSG(session, EINVAL,
"%s: file-rename: file has open handles", to);
#endif