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
Fix windows logging .. Call _locking repeatedly .. Becuase Windows gives up
[idzebra-moved-to-github.git]
/
util
/
flock.c
diff --git
a/util/flock.c
b/util/flock.c
index
62fd4ac
..
66f2709
100644
(file)
--- a/
util/flock.c
+++ b/
util/flock.c
@@
-1,4
+1,4
@@
-/* $Id: flock.c,v 1.1 2006-03-23 09:15:25 adam Exp $
+/* $Id: flock.c,v 1.4 2006-03-24 13:33:57 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
Copyright (C) 1995-2005
Index Data ApS
@@
-37,11
+37,15
@@
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include <idzebra/flock.h>
#include <yaz/xmalloc.h>
#include <idzebra/flock.h>
#include <yaz/xmalloc.h>
+#include <yaz/log.h>
struct zebra_lock_info {
int fd;
struct zebra_lock_info {
int fd;
+ char *fname;
};
};
+int log_level = 0 /* YLOG_LOG|YLOG_FLUSH */;
+
char *zebra_mk_fname (const char *dir, const char *name)
{
int dlen = dir ? strlen(dir) : 0;
char *zebra_mk_fname (const char *dir, const char *name)
{
int dlen = dir ? strlen(dir) : 0;
@@
-93,7
+97,8
@@
ZebraLockHandle zebra_lock_create (const char *dir, const char *name)
xfree (h);
h = 0;
}
xfree (h);
h = 0;
}
- xfree (fname);
+ h->fname = fname;
+ yaz_log(log_level, "zebra_lock_create fd=%d p=%p fname=%s", h->fd, h, h->fname);
return h;
}
return h;
}
@@
-101,8
+106,10
@@
void zebra_lock_destroy (ZebraLockHandle h)
{
if (!h)
return;
{
if (!h)
return;
+ yaz_log(log_level, "zebra_lock_destroy fd=%d p=%p fname=%s", h->fd, h, h->fname);
if (h->fd != -1)
close (h->fd);
if (h->fd != -1)
close (h->fd);
+ xfree (h->fname);
xfree (h);
}
xfree (h);
}
@@
-119,24
+126,35
@@
static int unixLock (int fd, int type, int cmd)
int zebra_lock_w (ZebraLockHandle h)
{
int zebra_lock_w (ZebraLockHandle h)
{
+ int r;
+ yaz_log(log_level, "zebra_lock_w fd=%d p=%p fname=%s", h->fd, h, h->fname);
#ifdef WIN32
#ifdef WIN32
- return _locking (h->fd, _LK_LOCK, 1);
+ while ((r = _locking (h->fd, _LK_LOCK, 1)))
+ ;
#else
#else
- return unixLock (h->fd, F_WRLCK, F_SETLKW);
+ r = unixLock (h->fd, F_WRLCK, F_SETLKW);
#endif
#endif
+ yaz_log(log_level, "zebra_lock_w fd=%d p=%p fname=%s OK", h->fd, h, h->fname);
+ return r;
}
int zebra_lock_r (ZebraLockHandle h)
{
}
int zebra_lock_r (ZebraLockHandle h)
{
+ int r;
+ yaz_log(log_level, "zebra_lock_r fd=%d p=%p fname=%s", h->fd, h, h->fname);
#ifdef WIN32
#ifdef WIN32
- return _locking (h->fd, _LK_LOCK, 1);
+ while ((r = _locking (h->fd, _LK_LOCK, 1)))
+ ;
#else
#else
- return unixLock (h->fd, F_RDLCK, F_SETLKW);
+ r = unixLock (h->fd, F_RDLCK, F_SETLKW);
#endif
#endif
+ yaz_log(log_level, "zebra_lock_r fd=%d p=%p fname=%s OK", h->fd, h, h->fname);
+ return r;
}
int zebra_unlock (ZebraLockHandle h)
{
}
int zebra_unlock (ZebraLockHandle h)
{
+ yaz_log(log_level, "zebra_unlock fd=%d p=%p fname=%s", h->fd, h, h->fname);
#ifdef WIN32
return _locking (h->fd, _LK_UNLCK, 1);
#else
#ifdef WIN32
return _locking (h->fd, _LK_UNLCK, 1);
#else