summaryrefslogtreecommitdiff
path: root/src/include/cursor.i
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2013-11-15 14:43:18 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2013-11-15 14:43:18 +1100
commit49211c1e1125ff4e04dacf82b48800d2a26f83e3 (patch)
tree0cfbacde09938bba0c9da872d1f14057c975668f /src/include/cursor.i
parent43bea10334a66c047046abaa45ad5797099455ec (diff)
downloadmongo-49211c1e1125ff4e04dacf82b48800d2a26f83e3.tar.gz
Move the cache full check to cursor enter, when there are no cursors positioned.
Diffstat (limited to 'src/include/cursor.i')
-rw-r--r--src/include/cursor.i20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/include/cursor.i b/src/include/cursor.i
index 68161965629..a0f7de4c243 100644
--- a/src/include/cursor.i
+++ b/src/include/cursor.i
@@ -76,12 +76,6 @@ __cursor_leave(WT_CURSOR_BTREE *cbt)
WT_RET(__wt_page_release(session, cbt->page));
cbt->page = NULL;
- /*
- * Check whether the cache is full. We may have other cursors open,
- * but the one we just closed might help eviction make progress.
- */
- WT_RET(__wt_cache_full_check(session));
-
return (0);
}
@@ -89,16 +83,24 @@ __cursor_leave(WT_CURSOR_BTREE *cbt)
* __cursor_enter --
* Setup the cursor's state for a new call.
*/
-static inline void
+static inline int
__cursor_enter(WT_CURSOR_BTREE *cbt)
{
WT_SESSION_IMPL *session;
session = (WT_SESSION_IMPL *)cbt->iface.session;
- if (session->ncursors++ == 0)
+ /*
+ * If there are no other cursors positioned in the session, check
+ * whether the cache is full and then get a snapshot if necessary.
+ */
+ if (session->ncursors == 0) {
+ WT_RET(__wt_cache_full_check(session));
__wt_txn_read_first(session);
+ }
+ ++session->ncursors;
F_SET(cbt, WT_CBT_ACTIVE);
+ return (0);
}
/*
@@ -115,7 +117,7 @@ __cursor_func_init(WT_CURSOR_BTREE *cbt, int reenter)
if (reenter)
WT_RET(__cursor_leave(cbt));
if (!F_ISSET(cbt, WT_CBT_ACTIVE))
- __cursor_enter(cbt);
+ WT_RET(__cursor_enter(cbt));
__wt_txn_cursor_op(session);
return (0);
}