always obtain write lock when updating version->{records,bytes}
This commit is contained in:
committed by
Ondřej Surý
parent
7e6d76e7db
commit
0cda448248
@@ -5751,6 +5751,7 @@ update_recordsandbytes(bool add, rbtdb_version_t *rbtversion,
|
||||
unsigned char *hdr = (unsigned char *)header;
|
||||
size_t hdrsize = sizeof (*header);
|
||||
|
||||
RWLOCK(&rbtversion->rwlock, isc_rwlocktype_write);
|
||||
if (add) {
|
||||
rbtversion->records += dns_rdataslab_count(hdr, hdrsize);
|
||||
rbtversion->bytes += dns_rdataslab_size(hdr, hdrsize);
|
||||
@@ -5758,6 +5759,7 @@ update_recordsandbytes(bool add, rbtdb_version_t *rbtversion,
|
||||
rbtversion->records -= dns_rdataslab_count(hdr, hdrsize);
|
||||
rbtversion->bytes -= dns_rdataslab_size(hdr, hdrsize);
|
||||
}
|
||||
RWUNLOCK(&rbtversion->rwlock, isc_rwlocktype_write);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
@@ -6144,12 +6146,8 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, rbtdb_version_t *rbtversion,
|
||||
rbtnode->data = newheader;
|
||||
newheader->next = topheader->next;
|
||||
if (rbtversion != NULL && !header_nx) {
|
||||
RWLOCK(&rbtversion->rwlock,
|
||||
isc_rwlocktype_write);
|
||||
update_recordsandbytes(false, rbtversion,
|
||||
header);
|
||||
RWUNLOCK(&rbtversion->rwlock,
|
||||
isc_rwlocktype_write);
|
||||
}
|
||||
free_rdataset(rbtdb, rbtdb->common.mctx, header);
|
||||
} else {
|
||||
@@ -6199,12 +6197,8 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, rbtdb_version_t *rbtversion,
|
||||
}
|
||||
}
|
||||
if (rbtversion != NULL && !header_nx) {
|
||||
RWLOCK(&rbtversion->rwlock,
|
||||
isc_rwlocktype_write);
|
||||
update_recordsandbytes(false, rbtversion,
|
||||
header);
|
||||
RWUNLOCK(&rbtversion->rwlock,
|
||||
isc_rwlocktype_write);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -6280,9 +6274,7 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, rbtdb_version_t *rbtversion,
|
||||
}
|
||||
|
||||
if (rbtversion != NULL && !newheader_nx) {
|
||||
RWLOCK(&rbtversion->rwlock, isc_rwlocktype_write);
|
||||
update_recordsandbytes(true, rbtversion, newheader);
|
||||
RWUNLOCK(&rbtversion->rwlock, isc_rwlocktype_write);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -7091,8 +7083,11 @@ rbt_datafixer(dns_rbtnode_t *rbtnode, void *base, size_t filesize,
|
||||
unsigned char *p = (unsigned char *) header;
|
||||
size_t size = dns_rdataslab_size(p, sizeof(*header));
|
||||
unsigned int count = dns_rdataslab_count(p, sizeof(*header));;
|
||||
RWLOCK(&rbtdb->current_version->rwlock, isc_rwlocktype_write);
|
||||
rbtdb->current_version->records += count;
|
||||
rbtdb->current_version->bytes += size;
|
||||
RWUNLOCK(&rbtdb->current_version->rwlock,
|
||||
isc_rwlocktype_write);
|
||||
isc_crc64_update(crc, p, size);
|
||||
#ifdef DEBUG
|
||||
hexdump("hashing header", p, sizeof(rdatasetheader_t));
|
||||
|
||||
Reference in New Issue
Block a user