Skip to content

Commit

Permalink
SQUASH into previous patch introducing shadow transactions
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Moore <paul@paul-moore.com>
  • Loading branch information
pcmoore committed Nov 4, 2019
1 parent b3a41aa commit 1c6f728
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,9 @@ static void _db_snap_release(struct db_filter_snap *snap)
{
unsigned int iter;

if (snap == NULL)
return;

if (snap->filter_cnt > 0) {
for (iter = 0; iter < snap->filter_cnt; iter++) {
if (snap->filters[iter])
Expand Down Expand Up @@ -2475,14 +2478,24 @@ void db_col_transaction_commit(struct db_filter_col *col)
if (snap == NULL)
return;

/* check for a shadow set by a higher transaction commit */
if (snap->shadow) {
/* leave the shadow intact, but drop the next snapshot */
if (snap->next) {
snap->next = snap->next->next;
_db_snap_release(snap->next);
}
return;
}

/* adjust the number of filters if needed */
if (col->filter_cnt > snap->filter_cnt) {
unsigned int tmp_i;
struct db_filter **tmp_f;

/* add filters */
tmp_f = realloc(snap->filters,
sizeof(struct db_filter *) * col->filter_cnt);
sizeof(struct db_filter *) * col->filter_cnt);
if (tmp_f == NULL)
goto shadow_err;
snap->filters = tmp_f;
Expand Down

0 comments on commit 1c6f728

Please sign in to comment.