From 95283c5c6fcd51a57d71649d65b4f2196c655a4f Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 27 Jun 2006 12:24:14 +0000 Subject: [PATCH] File lock fixes for Windows --- util/flock.c | 11 ++++++++--- util/tstflock.c | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/util/flock.c b/util/flock.c index 4953741..676b36a 100644 --- a/util/flock.c +++ b/util/flock.c @@ -1,4 +1,4 @@ -/* $Id: flock.c,v 1.8 2006-06-27 11:56:29 adam Exp $ +/* $Id: flock.c,v 1.9 2006-06-27 12:24:14 adam Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -114,15 +114,17 @@ char *zebra_mk_fname(const char *dir, const char *name) ZebraLockHandle zebra_lock_create(const char *dir, const char *name) { char *fname = zebra_mk_fname(dir, name); - struct zebra_lock_info *p; + struct zebra_lock_info *p = 0; ZebraLockHandle h = 0; assert(initialized); zebra_mutex_lock(&lock_list_mutex); +#ifndef WIN32 for (p = lock_list; p ; p = p->next) if (!strcmp(p->fname, fname)) break; +#endif if (!p) { p = (struct zebra_lock_info *) xmalloc(sizeof(*p)); @@ -163,7 +165,9 @@ ZebraLockHandle zebra_lock_create(const char *dir, const char *name) p->ref_count++; h = (ZebraLockHandle) xmalloc(sizeof(*h)); h->p = p; +#ifndef WIN32 h->write_flag = 0; +#endif } zebra_mutex_unlock(&lock_list_mutex); xfree(fname); /* free it - if it's still there */ @@ -239,8 +243,8 @@ int zebra_lock_w(ZebraLockHandle h) zebra_mutex_unlock(&h->p->file_mutex); zebra_lock_rdwr_wlock(&h->p->rdwr_lock); -#endif h->write_flag = 1; +#endif return r; } @@ -303,6 +307,7 @@ void zebra_flock_init() initialized = 1; zebra_mutex_init(&lock_list_mutex); } + yaz_log(log_level, "zebra_flock_init"); } /* diff --git a/util/tstflock.c b/util/tstflock.c index cf2039b..372f976 100644 --- a/util/tstflock.c +++ b/util/tstflock.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: tstflock.c,v 1.7 2006-06-27 11:56:29 adam Exp $ + * $Id: tstflock.c,v 1.8 2006-06-27 12:24:14 adam Exp $ */ #include @@ -96,7 +96,7 @@ static void tst_win32(int num) &dwThreadId[i]); /* returns the thread identifier */ } /* join */ - WaitForMultipleObjects(NUM_THREADS, handles, TRUE, INFINITE); + WaitForMultipleObjects(num, handles, TRUE, INFINITE); } #endif -- 1.7.10.4