From 0a92d9b74c7db4b0a48d1d23e2b7a4f2980d0085 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 24 Feb 2000 11:00:07 +0000 Subject: [PATCH] Fixed bug: indexer would run forever when lock dir was non-existant. --- index/index.h | 7 +++++-- index/lockidx.c | 16 +++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/index/index.h b/index/index.h index 50904d3..219ab38 100644 --- a/index/index.h +++ b/index/index.h @@ -137,7 +137,7 @@ int fileExtract (SYSNO *sysno, const char *fname, void zebraIndexLockMsg (const char *str); void zebraIndexUnlock (void); -void zebraIndexLock (BFiles bfs, int commitNow, const char *rval); +int zebraIndexLock (BFiles bfs, int commitNow, const char *rval); int zebraIndexWait (int commitPhase); #define FNAME_MAIN_LOCK "zebraidx.LCK" @@ -166,7 +166,10 @@ extern Res common_resource; /* * $Log: index.h,v $ - * Revision 1.67 1999-11-30 13:48:03 adam + * Revision 1.68 2000-02-24 11:00:07 adam + * Fixed bug: indexer would run forever when lock dir was non-existant. + * + * Revision 1.67 1999/11/30 13:48:03 adam * Improved installation. Updated for inclusion of YAZ header files. * * Revision 1.66 1999/07/14 13:21:34 heikki diff --git a/index/lockidx.c b/index/lockidx.c index 1469f01..7adf2eb 100644 --- a/index/lockidx.c +++ b/index/lockidx.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: lockidx.c,v $ - * Revision 1.17 1999-12-08 15:03:11 adam + * Revision 1.18 2000-02-24 11:00:07 adam + * Fixed bug: indexer would run forever when lock dir was non-existant. + * + * Revision 1.17 1999/12/08 15:03:11 adam * Implemented bf_reset. * * Revision 1.16 1999/02/02 14:50:57 adam @@ -177,14 +180,14 @@ void zebraIndexUnlock (void) logf (LOG_WARN|LOG_ERRNO, "unlink %s failed", path); } -void zebraIndexLock (BFiles bfs, int commitNow, const char *rval) +int zebraIndexLock (BFiles bfs, int commitNow, const char *rval) { char path[1024]; char buf[256]; int r; if (server_lock_main) - return ; + return 0; zebra_lock_prefix (common_resource, path); strcat (path, FNAME_MAIN_LOCK); @@ -196,10 +199,8 @@ void zebraIndexLock (BFiles bfs, int commitNow, const char *rval) server_lock_main = zebra_lock_create (path, 1); if (!server_lock_main) { - if (errno == ENOENT) - continue; - logf (LOG_FATAL|LOG_ERRNO, "open %s", path); - exit (1); + logf (LOG_FATAL, "couldn't obtain indexer lock"); + exit (1); } if (zebra_lock_nb (server_lock_main) == -1) { @@ -294,5 +295,6 @@ void zebraIndexLock (BFiles bfs, int commitNow, const char *rval) break; } zebra_lock (server_lock_main); + return 0; } -- 1.7.10.4