enabled. Fixed leak that could occur if zebra_begin_trans failed.
-/* $Id: bfile.c,v 1.42 2005-04-18 08:05:28 adam Exp $
+/* $Id: bfile.c,v 1.43 2005-05-17 08:50:48 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
unlink (bfs->cache_fname);
}
-void bf_cache (BFiles bfs, const char *spec)
+ZEBRA_RES bf_cache (BFiles bfs, const char *spec)
{
if (spec)
{
- yaz_log (YLOG_LOG, "enabling cache spec=%s", spec);
+ yaz_log (YLOG_LOG, "enabling shadow spec=%s", spec);
if (!bfs->commit_area)
bfs->commit_area = mf_init ("shadow", spec, bfs->base);
if (bfs->commit_area)
strcat (bfs->cache_fname, "/cache");
yaz_log (YLOG_LOG, "cache_fname = %s", bfs->cache_fname);
}
+ else
+ {
+ yaz_log(YLOG_WARN, "shadow could not be enabled");
+ return ZEBRA_FAIL;
+ }
}
else
bfs->commit_area = NULL;
+ return ZEBRA_OK;
}
int bf_close (BFile bf)
-/* $Id: mfile.c,v 1.60 2005-04-15 10:47:47 adam Exp $
+/* $Id: mfile.c,v 1.61 2005-05-17 08:50:48 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
if (!mf->wr && errno == ENOENT && off == 0)
return -2;
yaz_log (YLOG_WARN|YLOG_ERRNO, "Failed to open %s", mf->files[c].path);
- return -1;
+ return -1;
}
}
ps = pos - off;
-/* $Id: bfile.h,v 1.4 2005-03-30 09:25:23 adam Exp $
+/* $Id: bfile.h,v 1.5 2005-05-17 08:50:48 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
/* bf_cache: enables bfile cache if spec is not NULL */
YAZ_EXPORT
-void bf_cache (BFiles bfs, const char *spec);
+ZEBRA_RES bf_cache (BFiles bfs, const char *spec);
/* bf_commitExists: returns 1 if commit is pending; 0 otherwise */
YAZ_EXPORT
-/* $Id: zebraapi.c,v 1.168 2005-05-11 12:39:37 adam Exp $
+/* $Id: zebraapi.c,v 1.169 2005-05-17 08:50:49 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
reg->dh = data1_createx (DATA1_FLAG_XML);
if (!reg->dh)
+ {
+ xfree(reg);
return 0;
+ }
reg->bfs = bfs_create (res_get (res, "register"), reg_path);
if (!reg->bfs)
{
data1_destroy(reg->dh);
+ xfree(reg);
return 0;
}
if (useshadow)
- bf_cache (reg->bfs, res_get (res, "shadow"));
+ {
+ if (bf_cache (reg->bfs, res_get (res, "shadow")) == ZEBRA_FAIL)
+ {
+ bfs_destroy(reg->bfs);
+ data1_destroy(reg->dh);
+ xfree(reg);
+ return 0;
+ }
+ }
getcwd(cwd, sizeof(cwd)-1);
profilePath = res_get_def(res, "profilePath", DEFAULT_PROFILE_PATH);