From 42d50536651f28ee0b1eedce06d6f612d5a89a90 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Fri, 29 Apr 2016 12:48:57 +0200 Subject: 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. --- c_src/permdb.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'c_src') 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) { -- cgit v1.1