Skip to content

Commit

Permalink
Fix the types allocated to atomically swap into page structures.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Cahill committed Aug 26, 2013
1 parent 83d80a8 commit cc12bc0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions src/btree/col_modify.c
Expand Up @@ -20,7 +20,7 @@ __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int op)
WT_BTREE *btree;
WT_DECL_RET;
WT_INSERT *ins;
WT_INSERT_HEAD *ins_head, **ins_headp, *t;
WT_INSERT_HEAD *ins_head, **ins_headp;
WT_ITEM *value, _value;
WT_PAGE *page;
WT_UPDATE *old_upd, *upd, *upd_obsolete;
Expand Down Expand Up @@ -98,7 +98,7 @@ __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int op)
} else {
/* Allocate the append/update list reference as necessary. */
if (op == 1) {
if (page->modify->append == NULL) {
if ((ins_headp = page->modify->append) == NULL) {
WT_ERR(__wt_calloc_def(session, 1, &ins_headp));
if (WT_ATOMIC_CAS(
page->modify->append, NULL, ins_headp))
Expand All @@ -109,7 +109,7 @@ __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int op)
}
ins_headp = &page->modify->append[0];
} else if (page->type == WT_PAGE_COL_FIX) {
if (page->modify->update == NULL) {
if ((ins_headp = page->modify->update) == NULL) {
WT_ERR(__wt_calloc_def(session, 1, &ins_headp));
if (WT_ATOMIC_CAS(
page->modify->update, NULL, ins_headp))
Expand All @@ -120,7 +120,7 @@ __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int op)
}
ins_headp = &page->modify->update[0];
} else {
if (page->modify->update == NULL) {
if ((ins_headp = page->modify->update) == NULL) {
WT_ERR(__wt_calloc_def(
session, page->entries, &ins_headp));
if (WT_ATOMIC_CAS(
Expand All @@ -136,12 +136,12 @@ __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int op)

/* Allocate the WT_INSERT_HEAD structure as necessary. */
if ((ins_head = *ins_headp) == NULL) {
WT_ERR(__wt_calloc_def(session, 1, &t));
if (WT_ATOMIC_CAS(*ins_headp, NULL, t))
WT_ERR(__wt_calloc_def(session, 1, &ins_head));
if (WT_ATOMIC_CAS(*ins_headp, NULL, ins_head))
__wt_cache_page_inmem_incr(
session, page, sizeof(WT_INSERT_HEAD));
else
__wt_free(session, t);
__wt_free(session, ins_head);
ins_head = *ins_headp;
}

Expand Down
28 changes: 14 additions & 14 deletions src/btree/row_modify.c
Expand Up @@ -16,7 +16,7 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int is_remove)
{
WT_DECL_RET;
WT_INSERT *ins;
WT_INSERT_HEAD *ins_head, **ins_headp, *t;
WT_INSERT_HEAD *ins_head, **ins_headp;
WT_ITEM *key, *value;
WT_PAGE *page;
WT_UPDATE *old_upd, *upd, **upd_entry, *upd_obsolete;
Expand Down Expand Up @@ -49,16 +49,17 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int is_remove)
if (cbt->compare == 0) {
if (cbt->ins == NULL) {
/* Allocate an update array as necessary. */
if (page->u.row.upd == NULL) {
if ((upd_entry = page->u.row.upd) == NULL) {
WT_ERR(__wt_calloc_def(
session, page->entries, &upd));
if (WT_ATOMIC_CAS(page->u.row.upd, NULL, upd))
session, page->entries, &upd_entry));
if (WT_ATOMIC_CAS(
page->u.row.upd, NULL, upd_entry))
__wt_cache_page_inmem_incr(session,
page, page->entries *
sizeof(WT_UPDATE *));
else
__wt_free(session, upd);
upd = NULL;
__wt_free(session, upd_entry);
upd_entry = NULL;
}

/* Set the WT_UPDATE array reference. */
Expand Down Expand Up @@ -96,27 +97,26 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int is_remove)
ins_slot = F_ISSET(
cbt, WT_CBT_SEARCH_SMALLEST) ? page->entries : cbt->slot;

if (page->u.row.ins == NULL) {
if ((ins_headp = page->u.row.ins) == NULL) {
WT_ERR(__wt_calloc_def(
session, page->entries + 1, &ins));
if (WT_ATOMIC_CAS(page->u.row.ins, NULL, ins))
session, page->entries + 1, &ins_headp));
if (WT_ATOMIC_CAS(page->u.row.ins, NULL, ins_headp))
__wt_cache_page_inmem_incr(session,
page, (page->entries + 1) *
sizeof(WT_INSERT_HEAD *));
else
__wt_free(session, ins);
ins = NULL;
__wt_free(session, ins_headp);
}
ins_headp = &page->u.row.ins[ins_slot];

/* Allocate the WT_INSERT_HEAD structure as necessary. */
if ((ins_head = *ins_headp) == NULL) {
WT_ERR(__wt_calloc_def(session, 1, &t));
if (WT_ATOMIC_CAS(*ins_headp, NULL, t))
WT_ERR(__wt_calloc_def(session, 1, &ins_head));
if (WT_ATOMIC_CAS(*ins_headp, NULL, ins_head))
__wt_cache_page_inmem_incr(
session, page, sizeof(WT_INSERT_HEAD));
else
__wt_free(session, t);
__wt_free(session, ins_head);
ins_head = *ins_headp;
}

Expand Down

0 comments on commit cc12bc0

Please sign in to comment.