aboutsummaryrefslogtreecommitdiffstats
path: root/libibex/disktail.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-08-10 09:19:47 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-08-10 09:19:47 +0800
commited70b7f1412307294fd33e35aa981a37363c15e0 (patch)
tree918bd5948dea2c4c348ae0de3b932fb0a3054f66 /libibex/disktail.c
parentd471640fe82b68d5430514120dffa69be196f852 (diff)
downloadgsoc2013-evolution-ed70b7f1412307294fd33e35aa981a37363c15e0.tar
gsoc2013-evolution-ed70b7f1412307294fd33e35aa981a37363c15e0.tar.gz
gsoc2013-evolution-ed70b7f1412307294fd33e35aa981a37363c15e0.tar.bz2
gsoc2013-evolution-ed70b7f1412307294fd33e35aa981a37363c15e0.tar.lz
gsoc2013-evolution-ed70b7f1412307294fd33e35aa981a37363c15e0.tar.xz
gsoc2013-evolution-ed70b7f1412307294fd33e35aa981a37363c15e0.tar.zst
gsoc2013-evolution-ed70b7f1412307294fd33e35aa981a37363c15e0.zip
NOOP if writing to a failed file. (word_index_pre): NOOP if failed file.
2001-08-10 Not Zed <NotZed@Ximian.com> * wordindexmem.c (sync_cache_entry): NOOP if writing to a failed file. (word_index_pre): NOOP if failed file. (ibex_create_word_index_mem): Setup blocks value. ** Added internal exception handling to libibex, in the case of errors with on-disk data, exceptions are returned. * block.c (ibex_block_cache_open): Detect fatal errors below us and clean up appropriately. (ibex_block_cache_fail): New function to handle the failure, and keep track of it. (ibex_block_cache_sync): Dont do anything if we've failed on this file. * disktail.c (tail_compress): Add blocks param so we can assert for exceptions. * hash.c, block.c disktail.c: g_assert->ibex_block_cache_assert where dealing with external data. * hash.c (hash_info): Add index param so we can assert for exceptions. * ibex_block.c (ibex_index_buffer): Setjmp before calling into internal routines. (ibex_save): " (ibex_unindex): " (ibex_find): " (ibex_find_name): " (ibex_contains_name): " (ibex_reset): Function to reset the index file if we have an error, call when we have an error. * block.h (ibex_block_cache_assert): Create assertion/exception macros, and include a setjmp buffer for returning it. 2001-08-09 Not Zed <NotZed@Ximian.com> * Makefile.am (libibex_la_SOURCES): Remove wordindex.c, wordindexmem is what's used. svn path=/trunk/; revision=11864
Diffstat (limited to 'libibex/disktail.c')
-rw-r--r--libibex/disktail.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/libibex/disktail.c b/libibex/disktail.c
index b7f0091243..50c21afa9c 100644
--- a/libibex/disktail.c
+++ b/libibex/disktail.c
@@ -105,7 +105,7 @@ tail_info(struct _tailblock *bucket, nameid_t tailid, blockid_t **startptr)
/* compresses (or expand) the bucket entry, to the new size */
static void
-tail_compress(struct _tailblock *bucket, int index, int newsize)
+tail_compress(struct _memcache *blocks, struct _tailblock *bucket, int index, int newsize)
{
int i;
blockid_t *start, *end, *newstart;
@@ -170,10 +170,10 @@ tail_compress(struct _tailblock *bucket, int index, int newsize)
/* fixup data */
newstart = &bucket->tb_data[bucket->tb_offset[bucket->used-1]];
- g_assert(newstart+(end-start)-newsize <= &bucket->tb_data[sizeof(bucket->tb_data)/sizeof(bucket->tb_data[0])]);
- g_assert(newstart + (start-newstart) + MIN(end-start, newsize) <= &bucket->tb_data[sizeof(bucket->tb_data)/sizeof(bucket->tb_data[0])]);
- g_assert(newstart+(end-start)-newsize >= (blockid_t *) &bucket->tb_offset[bucket->used]);
- g_assert(newstart + (start-newstart) + MIN(end-start, newsize) >= (blockid_t *) &bucket->tb_offset[bucket->used]);
+ ibex_block_cache_assert(blocks, newstart+(end-start)-newsize <= &bucket->tb_data[sizeof(bucket->tb_data)/sizeof(bucket->tb_data[0])]);
+ ibex_block_cache_assert(blocks, newstart + (start-newstart) + MIN(end-start, newsize) <= &bucket->tb_data[sizeof(bucket->tb_data)/sizeof(bucket->tb_data[0])]);
+ ibex_block_cache_assert(blocks, newstart+(end-start)-newsize >= (blockid_t *) &bucket->tb_offset[bucket->used]);
+ ibex_block_cache_assert(blocks, newstart + (start-newstart) + MIN(end-start, newsize) >= (blockid_t *) &bucket->tb_offset[bucket->used]);
memmove(newstart+(end-start)-newsize, newstart, ((start-newstart)+MIN(end-start, newsize)) * sizeof(blockid_t));
@@ -240,14 +240,14 @@ tail_get(struct _memcache *blocks, int size)
d(printf("allocated %d (%d), used %d\n", tailid, tailid, tail->used));
ibex_block_dirty((struct _block *)tail);
- g_assert(&tail->tb_offset[tail->used-1]
- < (unsigned char *) &tail->tb_data[tail->tb_offset[tail->used-1]]);
+ ibex_block_cache_assert(blocks, &tail->tb_offset[tail->used-1]
+ < (unsigned char *) &tail->tb_data[tail->tb_offset[tail->used-1]]);
return tailid;
}
- g_assert(&tail->tb_offset[tail->used-1]
- < (unsigned char *) &tail->tb_data[tail->tb_offset[tail->used-1]]);
+ ibex_block_cache_assert(blocks, &tail->tb_offset[tail->used-1]
+ < (unsigned char *) &tail->tb_data[tail->tb_offset[tail->used-1]]);
/* see if we have a free slot first */
freeindex = -1;
@@ -278,7 +278,7 @@ tail_get(struct _memcache *blocks, int size)
tail->tb_offset[tail->used] = tail->tb_offset[tail->used-1];
tail->used++;
}
- tail_compress(tail, freeindex, size);
+ tail_compress(blocks, tail, freeindex, size);
ibex_block_dirty((struct _block *)tail);
d(printf("allocated %d (%d), used %d\n", tailid, TAIL_KEY(tailid, freeindex), tail->used));
return TAIL_KEY(tailid, freeindex);
@@ -315,11 +315,11 @@ tail_free(struct _memcache *blocks, blockid_t tailid)
tail = (struct _tailblock *)ibex_block_read(blocks, TAIL_BLOCK(tailid));
d(printf(" tail %d used %d\n", tailid, tail->used));
- g_assert(tail->used);
+ ibex_block_cache_assert(blocks, tail->used);
if (TAIL_INDEX(tailid) == tail->used - 1) {
tail->used --;
} else {
- tail_compress(tail, TAIL_INDEX(tailid), 0);
+ tail_compress(blocks, tail, TAIL_INDEX(tailid), 0);
}
ibex_block_dirty((struct _block *)tail);
}
@@ -391,7 +391,7 @@ disk_add_blocks_internal(struct _IBEXStore *store, blockid_t *headptr, blockid_t
int space, copied = 0, left;
/* assumes this funciton is in control of any tail creation */
- g_assert(tail == 0);
+ ibex_block_cache_assert(store->blocks, tail == 0);
d(printf("Adding %d items to block list\n", data->len));
@@ -519,7 +519,7 @@ disk_add_list(struct _IBEXStore *store, blockid_t *headptr, blockid_t *tailptr,
head = disk_add_blocks_internal(store, headptr, tailptr, tmpdata);
} else if (tail_space(tailblock) >= data->len) {
/* can we just expand this in our node, or do we need a new one? */
- tail_compress(tailblock, TAIL_INDEX(tail), data->len + len);
+ tail_compress(store->blocks, tailblock, TAIL_INDEX(tail), data->len + len);
memcpy(&tailblock->tb_data[tailblock->tb_offset[TAIL_INDEX(tail)] + len],
data->data, data->len * sizeof(blockid_t));
ibex_block_dirty((struct _block *)tailblock);
@@ -625,7 +625,7 @@ disk_remove(struct _IBEXStore *store, blockid_t *headptr, blockid_t *tailptr, na
ibex_block_dirty((struct _block *)tailblock);
*tailptr = 0;
} else {
- tail_compress(tailblock, TAIL_INDEX(tail), len-1);
+ tail_compress(store->blocks, tailblock, TAIL_INDEX(tail), len-1);
ibex_block_dirty((struct _block *)tailblock);
}
}
@@ -654,7 +654,7 @@ static void disk_free(struct _IBEXStore *store, blockid_t head, blockid_t tail)
if (tail) {
struct _tailblock *tailblock = (struct _tailblock *)ibex_block_read(store->blocks, TAIL_BLOCK(tail));
d(printf("freeing tail block %d (%d)\n", TAIL_BLOCK(tail), tail));
- tail_compress(tailblock, TAIL_INDEX(tail), 0);
+ tail_compress(store->blocks, tailblock, TAIL_INDEX(tail), 0);
ibex_block_dirty((struct _block *)tailblock);
}
}