-/* $Id: bfile.c,v 1.48 2006-08-14 10:40:05 adam Exp $
+/* $Id: bfile.c,v 1.49 2006-10-09 22:10:00 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
{
if (!bfs)
return;
- mf_reset (bfs->commit_area);
- mf_reset (bfs->register_area);
+ mf_reset(bfs->commit_area, 1);
+ mf_reset(bfs->register_area, 1);
}
void bf_commitExec (BFiles bfs)
mustDisable = 1;
}
- if (!(inf = open_cache (bfs, "rb")))
- return ;
- while (fscanf (inf, "%s %d", path, &block_size) == 2)
- {
- mf = mf_open (bfs->register_area, path, block_size, 0);
- cf = cf_open (mf, bfs->commit_area, path, block_size, 1, &firstTime);
- cf_unlink (cf);
- cf_close (cf);
- mf_close (mf);
- }
- fclose (inf);
+ mf_reset(bfs->commit_area, 1);
+
unlink_cache (bfs);
if (mustDisable)
bf_cache (bfs, 0);
-/* $Id: cfile.h,v 1.19 2006-08-14 10:40:05 adam Exp $
+/* $Id: cfile.h,v 1.20 2006-10-09 22:10:00 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
int wflag, int *firstp);
int cf_read (CFile cf, zint no, int offset, int nbytes, void *buf);
int cf_write (CFile cf, zint no, int offset, int nbytes, const void *buf);
-void cf_unlink (CFile cf);
void cf_commit (CFile cf);
YAZ_END_CDECL
-/* $Id: commit.c,v 1.28 2006-08-14 10:40:05 adam Exp $
+/* $Id: commit.c,v 1.29 2006-10-09 22:10:00 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
#define CF_OPTIMIZE_COMMIT 0
-void cf_unlink(CFile cf)
-{
- if (cf->bucket_in_memory)
- {
- yaz_log (YLOG_FATAL, "Cannot unlink potential dirty cache");
- exit (1);
- }
- cf->head.state = 0;
- cf->dirty = 1;
- mf_unlink (cf->block_mf);
- mf_unlink (cf->hash_mf);
-}
-
-
#if CF_OPTIMIZE_COMMIT
struct map_cache_entity {
int from;
-/* $Id: mfile.c,v 1.67 2006-08-14 10:40:05 adam Exp $
+/* $Id: mfile.c,v 1.68 2006-10-09 22:10:00 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
meta_f->next = ma->mfiles;
meta_f->open = 0;
meta_f->cur_file = -1;
- meta_f->unlink_flag = 0;
ma->mfiles = meta_f;
strcpy(meta_f->name, metaname);
part_f = &meta_f->files[0];
dp = dp->next;
xfree (d);
}
- meta_f = ma->mfiles;
- while (meta_f)
- {
- int i;
- meta_file *m = meta_f;
-
- for (i = 0; i<m->no_files; i++)
- {
- xfree (m->files[i].path);
- }
- zebra_mutex_destroy (&meta_f->mutex);
- meta_f = meta_f->next;
- xfree (m);
- }
+ mf_reset(ma, 0);
xfree (ma);
}
-void mf_reset(MFile_area ma)
+void mf_reset(MFile_area ma, int unlink_flag)
{
meta_file *meta_f;
int i;
meta_file *m = meta_f;
+ meta_f = meta_f->next;
+
assert (!m->open);
for (i = 0; i<m->no_files; i++)
{
- unlink (m->files[i].path);
+ if (unlink_flag)
+ unlink (m->files[i].path);
xfree (m->files[i].path);
}
- meta_f = meta_f->next;
+ zebra_mutex_destroy (&m->mutex);
xfree (m);
}
ma->mfiles = 0;
/*
* Open a metafile.
- * If !ma, Use MF_DEFAULT_AREA.
*/
MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag)
{
mnew->files[0].top = -1;
mnew->files[0].number = 0;
mnew->files[0].fd = -1;
- mnew->unlink_flag = 0;
mnew->min_bytes_creat = MF_MIN_BLOCKS_CREAT * block_size;
for (dp = ma->dirs; dp && dp->max_bytes >= 0 && dp->avail_bytes <
mnew->min_bytes_creat; dp = dp->next);
{
int i;
- yaz_log (YLOG_DEBUG, "mf_close(%s) unlink=%d", mf->name, mf->unlink_flag);
+ yaz_log (YLOG_DEBUG, "mf_close(%s)", mf->name);
assert(mf->open);
for (i = 0; i < mf->no_files; i++)
{
close(mf->files[i].fd);
mf->files[i].fd = -1;
}
- if (mf->unlink_flag)
- unlink(mf->files[i].path);
}
mf->open = 0;
return 0;
return 0;
}
-/*
- * Destroy a metafile, unlinking component files. File must be open.
- */
-int mf_unlink(MFile mf)
-{
- if (mf->open)
- {
- mf->unlink_flag = 1;
- }
- else
- {
- int i;
- for (i = 0; i<mf->no_files; i++)
- unlink(mf->files[i].path);
- }
- return 0;
-}
-
int mf_area_directory_stat(MFile_area ma, int no, const char **directory,
double *used_bytes, double *max_bytes)
{
-/* $Id: mfile.h,v 1.6 2006-08-14 10:40:05 adam Exp $
+/* $Id: mfile.h,v 1.7 2006-10-09 22:10:00 adam Exp $
Copyright (C) 1995-2006
Index Data ApS
int no_files;
int cur_file;
int open; /* is this file open? */
- int unlink_flag;
int blocksize;
mfile_off_t min_bytes_creat; /* minimum bytes required to enter directory */
MFile_area ma;
int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf);
/*
- * Destroy a metafile, unlinking component files. File must be open.
- */
-int mf_unlink(MFile mf);
-
-
-/*
* Destroy all metafiles. No files may be opened.
*/
-void mf_reset(MFile_area ma);
+void mf_reset(MFile_area ma, int unlink_flag);
/* \brief gets statistics about directory in metafile area
\param ma the area