projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Version 2.0.54
[idzebra-moved-to-github.git]
/
bfile
/
cfile.c
diff --git
a/bfile/cfile.c
b/bfile/cfile.c
index
0809ff9
..
76d77a5
100644
(file)
--- a/
bfile/cfile.c
+++ b/
bfile/cfile.c
@@
-1,8
+1,5
@@
-/* $Id: cfile.c,v 1.41 2006-12-19 13:55:05 adam Exp $
- Copyright (C) 1995-2006
- Index Data ApS
-
-This file is part of the Zebra server.
+/* This file is part of the Zebra server.
+ Copyright (C) 2004-2013 Index Data
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
@@
-20,6
+17,9
@@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
@@
-29,7
+29,7
@@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "mfile.h"
#include "cfile.h"
#include "mfile.h"
#include "cfile.h"
-/* set to 1 if extra commit/shadow check is to be performed */
+/** \brief set to 1 if extra commit/shadow check is to be performed */
#define EXTRA_CHECK 0
static int write_head(CFile cf)
#define EXTRA_CHECK 0
static int write_head(CFile cf)
@@
-90,10
+90,10
@@
CFile cf_open(MFile mf, MFile_area area, const char *fname,
memset(cf, 'Z', sizeof(*cf));
yaz_log(YLOG_DEBUG, "cf: open %s %s", fname, wflag ? "rdwr" : "rd");
memset(cf, 'Z', sizeof(*cf));
yaz_log(YLOG_DEBUG, "cf: open %s %s", fname, wflag ? "rdwr" : "rd");
-
+
cf->block_mf = 0;
cf->hash_mf = 0;
cf->block_mf = 0;
cf->hash_mf = 0;
- cf->rmf = mf;
+ cf->rmf = mf;
assert(firstp);
assert(firstp);
@@
-134,11
+134,11
@@
CFile cf_open(MFile mf, MFile_area area, const char *fname,
if (ret == 0 || !cf->head.state)
{
*firstp = 1;
if (ret == 0 || !cf->head.state)
{
*firstp = 1;
- cf->head.state = 1;
+ cf->head.state = CFILE_STATE_HASH;
cf->head.block_size = block_size;
cf->head.hash_size = 199;
hash_bytes = cf->head.hash_size * sizeof(zint);
cf->head.block_size = block_size;
cf->head.hash_size = 199;
hash_bytes = cf->head.hash_size * sizeof(zint);
- cf->head.flat_bucket = cf->head.next_bucket = cf->head.first_bucket =
+ cf->head.flat_bucket = cf->head.next_bucket = cf->head.first_bucket =
(hash_bytes+sizeof(cf->head))/HASH_BSIZE + 2;
cf->head.next_block = 1;
cf->array = (zint *) xmalloc(hash_bytes);
(hash_bytes+sizeof(cf->head))/HASH_BSIZE + 2;
cf->head.next_block = 1;
cf->array = (zint *) xmalloc(hash_bytes);
@@
-166,7
+166,7
@@
CFile cf_open(MFile mf, MFile_area area, const char *fname,
hash_bytes = cf->head.hash_size * sizeof(zint);
assert(cf->head.next_bucket > 0);
assert(cf->head.next_block > 0);
hash_bytes = cf->head.hash_size * sizeof(zint);
assert(cf->head.next_bucket > 0);
assert(cf->head.next_block > 0);
- if (cf->head.state == 1)
+ if (cf->head.state == CFILE_STATE_HASH)
cf->array = (zint *) xmalloc(hash_bytes);
else
cf->array = NULL;
cf->array = (zint *) xmalloc(hash_bytes);
else
cf->array = NULL;
@@
-176,7
+176,7
@@
CFile cf_open(MFile mf, MFile_area area, const char *fname,
return 0;
}
}
return 0;
}
}
- if (cf->head.state == 1)
+ if (cf->head.state == CFILE_STATE_HASH)
{
cf->parray = (struct CFile_hash_bucket **)
xmalloc(cf->head.hash_size * sizeof(*cf->parray));
{
cf->parray = (struct CFile_hash_bucket **)
xmalloc(cf->head.hash_size * sizeof(*cf->parray));
@@
-205,7
+205,7
@@
static void release_bucket(CFile cf, struct CFile_hash_bucket *p)
*p->h_prev = p->h_next;
if (p->h_next)
p->h_next->h_prev = p->h_prev;
*p->h_prev = p->h_next;
if (p->h_next)
p->h_next->h_prev = p->h_prev;
-
+
--(cf->bucket_in_memory);
xfree(p);
}
--(cf->bucket_in_memory);
xfree(p);
}
@@
-254,7
+254,7
@@
static struct CFile_hash_bucket *alloc_bucket(CFile cf, zint block_no, int hno)
cf->bucket_lru_front->lru_next = p;
else
cf->bucket_lru_back = p;
cf->bucket_lru_front->lru_next = p;
else
cf->bucket_lru_back = p;
- cf->bucket_lru_front = p;
+ cf->bucket_lru_front = p;
pp = cf->parray + hno;
p->h_next = *pp;
pp = cf->parray + hno;
p->h_next = *pp;
@@
-396,9
+396,9
@@
static int cf_moveto_flat(CFile cf)
yaz_log(YLOG_DEBUG, "cf: Moving to flat shadow: %s", cf->rmf->name);
yaz_log(YLOG_DEBUG, "cf: hits=%d miss=%d bucket_in_memory=" ZINT_FORMAT " total="
ZINT_FORMAT,
yaz_log(YLOG_DEBUG, "cf: Moving to flat shadow: %s", cf->rmf->name);
yaz_log(YLOG_DEBUG, "cf: hits=%d miss=%d bucket_in_memory=" ZINT_FORMAT " total="
ZINT_FORMAT,
- cf->no_hits, cf->no_miss, cf->bucket_in_memory,
+ cf->no_hits, cf->no_miss, cf->bucket_in_memory,
cf->head.next_bucket - cf->head.first_bucket);
cf->head.next_bucket - cf->head.first_bucket);
- assert(cf->head.state == 1);
+ assert(cf->head.state == CFILE_STATE_HASH);
if (flush_bucket(cf, -1))
return -1;
assert(cf->bucket_in_memory == 0);
if (flush_bucket(cf, -1))
return -1;
assert(cf->bucket_in_memory == 0);
@@
-425,7
+425,7
@@
static int cf_moveto_flat(CFile cf)
cf->array = NULL;
xfree(cf->parray);
cf->parray = NULL;
cf->array = NULL;
xfree(cf->parray);
cf->parray = NULL;
- cf->head.state = 2;
+ cf->head.state = CFILE_STATE_FLAT;
cf->dirty = 1;
return 0;
}
cf->dirty = 1;
return 0;
}
@@
-449,10
+449,10
@@
static zint cf_new_hash(CFile cf, zint no)
{
int hno = cf_hash(cf, no);
struct CFile_hash_bucket *hbprev = NULL, *hb = cf->parray[hno];
{
int hno = cf_hash(cf, no);
struct CFile_hash_bucket *hbprev = NULL, *hb = cf->parray[hno];
- zint *bucketpp = &cf->array[hno];
+ zint *bucketpp = &cf->array[hno];
int i;
zint vno = (cf->head.next_block)++;
int i;
zint vno = (cf->head.next_block)++;
-
+
for (hb = cf->parray[hno]; hb; hb = hb->h_next)
if (!hb->ph.vno[HASH_BUCKET-1])
for (i = 0; i<HASH_BUCKET; i++)
for (hb = cf->parray[hno]; hb; hb = hb->h_next)
if (!hb->ph.vno[HASH_BUCKET-1])
for (i = 0; i<HASH_BUCKET; i++)
@@
-542,7
+542,7
@@
int cf_read(CFile cf, zint no, int offset, int nbytes, void *buf)
{
zint block;
int ret;
{
zint block;
int ret;
-
+
assert(cf);
zebra_mutex_lock(&cf->mutex);
ret = cf_lookup(cf, no, &block);
assert(cf);
zebra_mutex_lock(&cf->mutex);
ret = cf_lookup(cf, no, &block);
@@
-645,6
+645,7
@@
int cf_close(CFile cf)
/*
* Local variables:
* c-basic-offset: 4
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab