diff options
author | Keith Bostic <keith@wiredtiger.com> | 2014-07-17 17:00:47 -0400 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2014-07-17 17:00:47 -0400 |
commit | 61c4f0a86e25118025bb81c41a00b9df04eb7ef2 (patch) | |
tree | 860cc97c85cb1d26114a894570f38c34d04fe46a | |
parent | d16d7229ea2d13733d2d637e0e80f7f25d011a6e (diff) | |
download | mongo-61c4f0a86e25118025bb81c41a00b9df04eb7ef2.tar.gz |
Rename __cursor_search_clear __cursor_pos_clear; it's the code that
clears a cursor's location, and is no longer unique to the search
functions.
Change __cursor_error_resolve cursor error resolution to clear the
cursor's location even if we see a failure from the cursor "leave"
function (probably a bad return from releasing a page), keeping the
cursor's location isn't likely to make anything better.
sename __cursor_error_resolve to __cursor_reset, it's a combination of
"leave the API" and "clear the cursor's location"; now that it clears
the cursor location regardless of the return from the cursor "leave"
function, we can call it from the WT_CURSOR.reset code, they're the
same.
-rw-r--r-- | src/btree/bt_curnext.c | 2 | ||||
-rw-r--r-- | src/btree/bt_curprev.c | 2 | ||||
-rw-r--r-- | src/btree/bt_cursor.c | 20 | ||||
-rw-r--r-- | src/btree/col_srch.c | 2 | ||||
-rw-r--r-- | src/btree/row_srch.c | 4 | ||||
-rw-r--r-- | src/include/cursor.i | 27 |
6 files changed, 26 insertions, 31 deletions
diff --git a/src/btree/bt_curnext.c b/src/btree/bt_curnext.c index dc729e748b6..caf3f9f369a 100644 --- a/src/btree/bt_curnext.c +++ b/src/btree/bt_curnext.c @@ -464,6 +464,6 @@ __wt_btcur_next(WT_CURSOR_BTREE *cbt, int truncating) } err: if (ret != 0) - WT_TRET(__cursor_error_resolve(cbt)); + WT_TRET(__cursor_reset(cbt)); return (ret); } diff --git a/src/btree/bt_curprev.c b/src/btree/bt_curprev.c index 8ad57002a29..4767762b564 100644 --- a/src/btree/bt_curprev.c +++ b/src/btree/bt_curprev.c @@ -555,6 +555,6 @@ __wt_btcur_prev(WT_CURSOR_BTREE *cbt, int truncating) } err: if (ret != 0) - WT_TRET(__cursor_error_resolve(cbt)); + WT_TRET(__cursor_reset(cbt)); return (ret); } diff --git a/src/btree/bt_cursor.c b/src/btree/bt_cursor.c index d2aac361ab3..64ff0bd9c69 100644 --- a/src/btree/bt_cursor.c +++ b/src/btree/bt_cursor.c @@ -268,7 +268,6 @@ __cursor_row_modify( int __wt_btcur_reset(WT_CURSOR_BTREE *cbt) { - WT_DECL_RET; WT_SESSION_IMPL *session; session = (WT_SESSION_IMPL *)cbt->iface.session; @@ -276,10 +275,7 @@ __wt_btcur_reset(WT_CURSOR_BTREE *cbt) WT_STAT_FAST_CONN_INCR(session, cursor_reset); WT_STAT_FAST_DATA_INCR(session, cursor_reset); - ret = __curfile_leave(cbt); - __cursor_search_clear(cbt); - - return (ret); + return (__cursor_reset(cbt)); } /* @@ -325,7 +321,7 @@ __wt_btcur_search(WT_CURSOR_BTREE *cbt) ret = WT_NOTFOUND; err: if (ret != 0) - WT_TRET(__cursor_error_resolve(cbt)); + WT_TRET(__cursor_reset(cbt)); return (ret); } @@ -405,7 +401,7 @@ __wt_btcur_search_near(WT_CURSOR_BTREE *cbt, int *exactp) } err: if (ret != 0) - WT_TRET(__cursor_error_resolve(cbt)); + WT_TRET(__cursor_reset(cbt)); if (exactp != NULL && (ret == 0 || ret == WT_NOTFOUND)) *exactp = exact; return (ret); @@ -501,7 +497,7 @@ err: if (ret == WT_RESTART) if (ret == 0) WT_TRET(__curfile_leave(cbt)); if (ret != 0) - WT_TRET(__cursor_error_resolve(cbt)); + WT_TRET(__cursor_reset(cbt)); return (ret); } @@ -547,7 +543,7 @@ err: if (ret == WT_RESTART) goto retry; WT_TRET(__curfile_leave(cbt)); if (ret != 0) - WT_TRET(__cursor_error_resolve(cbt)); + WT_TRET(__cursor_reset(cbt)); return (ret); } @@ -620,7 +616,7 @@ err: if (ret == WT_RESTART) ret = 0; if (ret != 0) - WT_TRET(__cursor_error_resolve(cbt)); + WT_TRET(__cursor_reset(cbt)); return (ret); } @@ -707,7 +703,7 @@ err: if (ret == WT_RESTART) WT_TRET(__wt_kv_return(session, cbt, cbt->modify_update)); if (ret != 0) - WT_TRET(__cursor_error_resolve(cbt)); + WT_TRET(__cursor_reset(cbt)); return (ret); } @@ -745,7 +741,7 @@ __wt_btcur_next_random(WT_CURSOR_BTREE *cbt) WT_ERR(__wt_btcur_search_near(cbt, 0)); err: if (ret != 0) - WT_TRET(__cursor_error_resolve(cbt)); + WT_TRET(__cursor_reset(cbt)); return (ret); } diff --git a/src/btree/col_srch.c b/src/btree/col_srch.c index d824339d1a0..e44dd3fce67 100644 --- a/src/btree/col_srch.c +++ b/src/btree/col_srch.c @@ -28,7 +28,7 @@ __wt_col_search(WT_SESSION_IMPL *session, btree = S2BT(session); - __cursor_search_clear(cbt); + __cursor_pos_clear(cbt); /* * In the service of eviction splits, we're only searching a single leaf diff --git a/src/btree/row_srch.c b/src/btree/row_srch.c index 9c391be2149..ad83ed005c6 100644 --- a/src/btree/row_srch.c +++ b/src/btree/row_srch.c @@ -147,7 +147,7 @@ __wt_row_search(WT_SESSION_IMPL *session, rip = NULL; match = 0; /* -Wuninitialized */ - __cursor_search_clear(cbt); + __cursor_pos_clear(cbt); /* * The row-store search routine uses a different comparison API. @@ -425,7 +425,7 @@ __wt_row_random(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt) btree = S2BT(session); - __cursor_search_clear(cbt); + __cursor_pos_clear(cbt); restart: /* Walk the internal pages of the tree. */ diff --git a/src/include/cursor.i b/src/include/cursor.i index f2713ad87d1..3f551efa17c 100644 --- a/src/include/cursor.i +++ b/src/include/cursor.i @@ -17,11 +17,11 @@ __cursor_set_recno(WT_CURSOR_BTREE *cbt, uint64_t v) } /* - * __cursor_search_clear -- - * Reset the cursor's state for a search. + * __cursor_pos_clear -- + * Reset the cursor's location. */ static inline void -__cursor_search_clear(WT_CURSOR_BTREE *cbt) +__cursor_pos_clear(WT_CURSOR_BTREE *cbt) { /* Our caller should have released any page held by this cursor. */ cbt->ref = NULL; @@ -148,22 +148,21 @@ __cursor_func_init(WT_CURSOR_BTREE *cbt, int reenter) } /* - * __cursor_error_resolve -- - * Resolve the cursor's state for return on error. + * __cursor_reset -- + * Reset the cursor. */ static inline int -__cursor_error_resolve(WT_CURSOR_BTREE *cbt) +__cursor_reset(WT_CURSOR_BTREE *cbt) { + WT_DECL_RET; + /* - * On error, we can't iterate, so clear the cursor's position and - * release any page references we're holding. + * The cursor is leaving the API, and no longer holds any position, + * generally called to clean up the cursor after an error. */ - WT_RET(__curfile_leave(cbt)); - - /* Clear the cursor's search state. */ - __cursor_search_clear(cbt); - - return (0); + ret = __curfile_leave(cbt); + __cursor_pos_clear(cbt); + return (ret); } /* |