summaryrefslogtreecommitdiff
path: root/c_src/permdb.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordu.net>2016-04-29 12:48:57 +0200
committerLinus Nordberg <linus@nordu.net>2016-04-29 12:48:57 +0200
commit42d50536651f28ee0b1eedce06d6f612d5a89a90 (patch)
treebfe7b86184504e03c83ffd05031cd1da57508bc2 /c_src/permdb.c
parentce461321ef514cc0b21e44e415eb05ad2122036b (diff)
Add error printout for the duplicate key case in rebuild_index_file().
Also moving the offset calculation to after the printout because the printout needs it before increasing it. Also turn two outcommented fprint's into dprintf's.
Diffstat (limited to 'c_src/permdb.c')
-rw-r--r--c_src/permdb.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/c_src/permdb.c b/c_src/permdb.c
index 2b14d0b..68fa695 100644
--- a/c_src/permdb.c
+++ b/c_src/permdb.c
@@ -370,33 +370,33 @@ rebuild_index_file(permdb_object *state)
if (cookie == NULL) {
break;
}
- if (memcmp(&data_entry_cookie, cookie, sizeof(data_entry_cookie))
- == 0) {
+ if (memcmp(&data_entry_cookie, cookie,
+ sizeof(data_entry_cookie)) == 0) {
size_t datalen;
unsigned char *datakey =
readdatakeyandlen(state, offset, &datalen);
- //fprintf(stderr, "entry %llu: %zu\n", offset, datalen);
+ dprintf(REBUILD,
+ (stderr, "entry %llu: %zu\n", offset, datalen));
int result =
addvalue(state, datakey, keylen, NULL, 0, offset);
- offset += sizeof(data_entry_cookie)
- + keylen
- + sizeof(uint32_t)
- + datalen;
-
free(datakey);
-
if (result != 1) {
+ fprintf(stderr, "duplicate key at %llu", offset);
free(cookie);
return -1;
}
+ offset += sizeof(data_entry_cookie)
+ + keylen
+ + sizeof(uint32_t)
+ + datalen;
} else if (memcmp(&data_commit_start_cookie, cookie,
sizeof(data_commit_start_cookie)) == 0) {
struct commit_info *data_commit =
read_data_commit_forward(state->datafile,
&offset);
- /*fprintf(stderr, "verifying commit: %llu %p\n", offset,
- data_commit);*/
-
+ dprintf(REBUILD,
+ (stderr, "verifying commit: %llu %p\n", offset,
+ data_commit));
if (data_commit == NULL
|| validate_checksum(data_commit,
state->datafile) < 0) {