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
Moved file locking utilities from index/lockutil.c to util/flock.c
[idzebra-moved-to-github.git]
/
index
/
zebraapi.c
diff --git
a/index/zebraapi.c
b/index/zebraapi.c
index
8207926
..
d89c263
100644
(file)
--- a/
index/zebraapi.c
+++ b/
index/zebraapi.c
@@
-1,4
+1,4
@@
-/* $Id: zebraapi.c,v 1.201 2006-02-09 08:31:02 adam Exp $
+/* $Id: zebraapi.c,v 1.204 2006-03-23 09:15:25 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
Copyright (C) 1995-2005
Index Data ApS
@@
-184,11
+184,18
@@
ZebraService zebra_start_res (const char *configName, Res def_res, Res over_res)
const char *passwd_plain = 0;
const char *passwd_encrypt = 0;
const char *dbaccess = 0;
const char *passwd_plain = 0;
const char *passwd_encrypt = 0;
const char *dbaccess = 0;
- ZebraService zh = xmalloc(sizeof(*zh));
+ ZebraService zh = 0;
if (configName)
if (configName)
- res_read_file(res, configName);
-
+ {
+ ZEBRA_RES ret = res_read_file(res, configName);
+ if (ret != ZEBRA_OK)
+ {
+ res_close(res);
+ return 0;
+ }
+ }
+ zh = xmalloc(sizeof(*zh));
zh->global_res = res;
zh->sessions = 0;
zh->global_res = res;
zh->sessions = 0;
@@
-321,7
+328,14
@@
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);
data1_set_tabroot (reg->dh, reg_path);
reg->recTypes = recTypes_init (zs->record_classes, reg->dh);
- reg->zebra_maps = zebra_maps_open (res, reg_path);
+ if ((reg->zebra_maps = zebra_maps_open (res, reg_path)) == 0) {
+ /* ### Do we need to destroy reg->recTypes? */
+ bfs_destroy(reg->bfs);
+ data1_destroy(reg->dh);
+ xfree(reg);
+ return 0;
+ }
+
reg->rank_classes = NULL;
reg->key_buf = 0;
reg->rank_classes = NULL;
reg->key_buf = 0;
@@
-687,11
+701,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 =
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 =
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)
{
if (!zh->lock_normal || !zh->lock_shadow)
{
@@
-2344,3
+2358,12
@@
void zebra_setError_zint(ZebraHandle zh, int code, zint i)
zh->errString = nmem_strdup(zh->nmem_error, vstr);
}
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, "/");
+}
+