X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Flockidx.c;h=26af6846cb55aadaf251ad61f9ec76c39bfbe296;hb=6f27675ef554a06c5996a8815ed24dd3e6171aa1;hp=1469f013399c8d2d2c4e1fa4c56c0873ba1af027;hpb=45a6ad99e5210bc4ef39bf00d81aee8f0fb26168;p=idzebra-moved-to-github.git diff --git a/index/lockidx.c b/index/lockidx.c index 1469f01..26af684 100644 --- a/index/lockidx.c +++ b/index/lockidx.c @@ -4,7 +4,16 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: lockidx.c,v $ - * Revision 1.17 1999-12-08 15:03:11 adam + * Revision 1.20 2000-10-16 20:16:00 adam + * Fixed problem with close of lock file for WIN32. + * + * Revision 1.19 2000/09/05 14:04:05 adam + * Updates for prefix 'yaz_' for YAZ log functions. + * + * 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 @@ -169,22 +178,28 @@ void zebraIndexUnlock (void) { char path[1024]; - zebra_lock_destroy (server_lock_main); - server_lock_main = 0; zebra_lock_prefix (common_resource, path); strcat (path, FNAME_MAIN_LOCK); +#ifdef WIN32 + zebra_lock_destroy (server_lock_main); if (unlink (path) && errno != ENOENT) logf (LOG_WARN|LOG_ERRNO, "unlink %s failed", path); +#else + if (unlink (path) && errno != ENOENT) + logf (LOG_WARN|LOG_ERRNO, "unlink %s failed", path); + zebra_lock_destroy (server_lock_main); +#endif + server_lock_main = 0; } -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 +211,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 +307,6 @@ void zebraIndexLock (BFiles bfs, int commitNow, const char *rval) break; } zebra_lock (server_lock_main); + return 0; }