diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2009-10-10 06:16:23 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2009-10-10 06:16:23 +0200 |
commit | 69a2548913619eb81dcb6c03e27585e02fe057cd (patch) | |
tree | 21fd934d184d8de3e0f58de8f9299da98cd2fe2e /src/rcclock.c | |
parent | 9e6ed416e3368b23c867e54dd2f7cc18f75a1c6e (diff) | |
download | librcc-69a2548913619eb81dcb6c03e27585e02fe057cd.tar.gz librcc-69a2548913619eb81dcb6c03e27585e02fe057cd.tar.bz2 librcc-69a2548913619eb81dcb6c03e27585e02fe057cd.tar.xz librcc-69a2548913619eb81dcb6c03e27585e02fe057cd.zip |
Support systems without lockf (OpenSolaris), check GTK1 headers in configure.in, complain on missing macros in autogen.sh, patches by Ivan Borzenkov and Colin Watson for eglibc compatibility
Diffstat (limited to 'src/rcclock.c')
-rw-r--r-- | src/rcclock.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/rcclock.c b/src/rcclock.c index 5683f44..b759189 100644 --- a/src/rcclock.c +++ b/src/rcclock.c @@ -40,6 +40,9 @@ #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif /* HAVE_SYS_STAT_H */ +#ifdef HAVE_FCNTL_H +# include <fcntl.h> +#endif /* HAVE_FCNTL_H */ #include "rcchome.h" #include "rcclock.h" @@ -70,7 +73,14 @@ int rccLock() { lockfd = open(stmp, O_RDWR|O_CREAT, 0644); if (lockfd >= 0) { for (err = -1, i = 0; i < (LIBRCC_LOCK_WAIT/10); i++) { +#if defined(HAVE_FLOCK) err = flock(lockfd, LOCK_EX|LOCK_NB); +#elif defined(HAVE_LOCKF) + err = lockf(lockfd, F_TLOCK, 1); +#else +# warning "No file locking mechanism is detected" + err = 0; // We must believe in best +#endif if ((err)&&(errno == EWOULDBLOCK)) nanosleep(&wait, NULL); else break; } @@ -85,7 +95,11 @@ int rccLock() { lockfd = open(stmp, O_RDWR|O_CREAT, 0644); if (lockfd >= 0) { for (err = -1, i = 0; i < (LIBRCC_LOCK_WAIT/10); i++) { +#if defined(HAVE_FLOCK) err = flock(lockfd, LOCK_EX|LOCK_NB); +#elif defined(HAVE_LOCKF) + err = lockf(lockfd, F_TLOCK, 1); +#endif if ((err)&&(errno == EWOULDBLOCK)) nanosleep(&wait, NULL); else break; } @@ -121,7 +135,12 @@ void rccUnLock() { sprintf(stmp,"%s/.rcc/locks/rcc.lock", rcc_home_dir); +#if defined(HAVE_FLOCK) flock(lockfd, LOCK_UN); +#elif defined(HAVE_LOCKF) + lockf(lockfd, F_ULOCK, 1); +#endif + close(lockfd); lockfd = -1; #endif /* HAVE_SYS_FILE_H */ |