X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=index%2Flocksrv.c;h=304dc88a2c936264f6ce646edf7b5fb630ecb3ae;hb=c5ef994b26d692fbfecc3ac97f69e4bf7bd0fcea;hp=5ea2c9214f2217c7a0693accb83b166811e9aae0;hpb=2954746ef5c897ec5e651cc2c39eda878f1d5da5;p=idzebra-moved-to-github.git diff --git a/index/locksrv.c b/index/locksrv.c index 5ea2c92..304dc88 100644 --- a/index/locksrv.c +++ b/index/locksrv.c @@ -1,10 +1,17 @@ /* - * Copyright (C) 1994-1996, Index Data I/S + * Copyright (C) 1994-1997, Index Data I/S * All rights reserved. * Sebastian Hammer, Adam Dickmeiss * * $Log: locksrv.c,v $ - * Revision 1.7 1997-09-04 13:58:04 adam + * Revision 1.9 1997-09-25 14:54:43 adam + * WIN32 files lock support. + * + * Revision 1.8 1997/09/17 12:19:15 adam + * Zebra version corresponds to YAZ version 1.4. + * Changed Zebra server so that it doesn't depend on global common_resource. + * + * Revision 1.7 1997/09/04 13:58:04 adam * Added O_BINARY for open calls. * * Revision 1.6 1996/10/29 14:06:52 adam @@ -32,7 +39,11 @@ */ #include #include +#ifdef WINDOWS +#include +#else #include +#endif #include #include #include @@ -40,30 +51,28 @@ #include "zserver.h" -static int server_lock_cmt = -1; -static int server_lock_org = -1; +static ZebraLockHandle server_lock_cmt = NULL; +static ZebraLockHandle server_lock_org = NULL; -int zebraServerLock (int commitPhase) +int zebraServerLock (Res res, int commitPhase) { char pathPrefix[1024]; char path[1024]; - zebraLockPrefix (pathPrefix); + zebraLockPrefix (res, pathPrefix); - if (server_lock_cmt == -1) + if (!server_lock_cmt) { sprintf (path, "%s%s", pathPrefix, FNAME_COMMIT_LOCK); - if ((server_lock_cmt = open (path, O_BINARY|O_CREAT|O_RDWR, 0666)) - == -1) + if (!(server_lock_cmt = zebra_lock_create (path, 0))) { logf (LOG_FATAL|LOG_ERRNO, "create %s", path); return -1; } - assert (server_lock_org == -1); + assert (server_lock_org == NULL); sprintf (path, "%s%s", pathPrefix, FNAME_ORG_LOCK); - if ((server_lock_org = open (path, O_BINARY|O_CREAT|O_RDWR, 0666)) - == -1) + if (!(server_lock_org = zebra_lock_create (path, 0))) { logf (LOG_FATAL|LOG_ERRNO, "create %s", path); return -1; @@ -72,33 +81,33 @@ int zebraServerLock (int commitPhase) if (commitPhase) { logf (LOG_DEBUG, "Server locks org"); - zebraLock (server_lock_org, 0); + zebra_lock (server_lock_org); } else { logf (LOG_DEBUG, "Server locks cmt"); - zebraLock (server_lock_cmt, 0); + zebra_lock (server_lock_cmt); } return 0; } void zebraServerUnlock (int commitPhase) { - if (server_lock_org == -1) + if (server_lock_org == NULL) return; if (commitPhase) { logf (LOG_DEBUG, "Server unlocks org"); - zebraUnlock (server_lock_org); + zebra_unlock (server_lock_org); } else { logf (LOG_DEBUG, "Server unlocks cmt"); - zebraUnlock (server_lock_cmt); + zebra_unlock (server_lock_cmt); } } -int zebraServerLockGetState (time_t *timep) +int zebraServerLockGetState (Res res, time_t *timep) { char pathPrefix[1024]; char path[1024]; @@ -106,7 +115,7 @@ int zebraServerLockGetState (time_t *timep) int fd; struct stat xstat; - zebraLockPrefix (pathPrefix); + zebraLockPrefix (res, pathPrefix); sprintf (path, "%s%s", pathPrefix, FNAME_TOUCH_TIME); if (stat (path, &xstat) == -1)