X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=b036ff1dc740ba3013ab9fa15c8cf6dec34d25f4;hb=6d3b83ae7e008f2d61326051b03f7f07d3cc2ef0;hp=cb05bb6d7c12af5e3d45be3d661fe6e545a59512;hpb=4e48a2f759ac1e7224f00d7c091bb840885cf7d2;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index cb05bb6..b036ff1 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.203 2006-03-13 17:42:09 mike Exp $ +/* $Id: zebraapi.c,v 1.205 2006-03-25 15:33:29 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -299,6 +299,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, reg->dh = data1_createx (DATA1_FLAG_XML); if (!reg->dh) { + xfree(reg->name); xfree(reg); return 0; } @@ -306,6 +307,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, if (!reg->bfs) { data1_destroy(reg->dh); + xfree(reg->name); xfree(reg); return 0; } @@ -315,6 +317,7 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, { bfs_destroy(reg->bfs); data1_destroy(reg->dh); + xfree(reg->name); xfree(reg); return 0; } @@ -328,10 +331,12 @@ struct zebra_register *zebra_register_open(ZebraService zs, const char *name, data1_set_tabroot (reg->dh, reg_path); reg->recTypes = recTypes_init (zs->record_classes, reg->dh); - if ((reg->zebra_maps = zebra_maps_open (res, reg_path)) == 0) { - /* ### Do we need to destroy reg->recTypes? */ + if ((reg->zebra_maps = zebra_maps_open (res, reg_path)) == 0) + { + recTypes_destroy(reg->recTypes); bfs_destroy(reg->bfs); data1_destroy(reg->dh); + xfree(reg->name); xfree(reg); return 0; } @@ -701,11 +706,11 @@ static void zebra_select_register (ZebraHandle zh, const char *new_reg) res_set (zh->res, "lockDir", zh->path_reg); sprintf (fname, "norm.%s.LCK", zh->reg_name); zh->lock_normal = - zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0); + zebra_lock_create (res_get(zh->res, "lockDir"), fname); sprintf (fname, "shadow.%s.LCK", zh->reg_name); zh->lock_shadow = - zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0); + zebra_lock_create (res_get(zh->res, "lockDir"), fname); if (!zh->lock_normal || !zh->lock_shadow) { @@ -1670,7 +1675,7 @@ ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw) yaz_log (YLOG_WARN, "previous transaction didn't reach commit"); bf_commitClean (bfs, rval); bfs_destroy (bfs); - } + } else { yaz_log (YLOG_WARN, "your previous transaction didn't finish"); @@ -2358,3 +2363,12 @@ void zebra_setError_zint(ZebraHandle zh, int code, zint i) zh->errString = nmem_strdup(zh->nmem_error, vstr); } +void zebra_lock_prefix (Res res, char *path) +{ + const char *lock_dir = res_get_def (res, "lockDir", ""); + + strcpy (path, lock_dir); + if (*path && path[strlen(path)-1] != '/') + strcat (path, "/"); +} +