summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2009-10-10 06:16:23 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2009-10-10 06:16:23 +0200
commit69a2548913619eb81dcb6c03e27585e02fe057cd (patch)
tree21fd934d184d8de3e0f58de8f9299da98cd2fe2e /src
parent9e6ed416e3368b23c867e54dd2f7cc18f75a1c6e (diff)
downloadlibrcc-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')
-rw-r--r--src/rcclock.c19
-rw-r--r--src/rccstring.h8
-rw-r--r--src/rccxml.c35
3 files changed, 55 insertions, 7 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 */
diff --git a/src/rccstring.h b/src/rccstring.h
index 40bda89..8bace94 100644
--- a/src/rccstring.h
+++ b/src/rccstring.h
@@ -38,13 +38,9 @@ int rccStringSetLang(rcc_string string, const char *sn);
int rccStringFixID(rcc_string string, rcc_context ctx);
int rccStringChangeID(rcc_string string, rcc_language_id language_id);
-#ifdef HAVE_STRNLEN
-# ifndef strnlen
-size_t strnlen(const char *str, size_t size);
-# endif /* !strnlen */
-#else
+#ifndef HAVE_STRNLEN
int rccStrnlen(const char *str, size_t size);
-#endif /* HAVE_STRNLEN */
+#endif /* !HAVE_STRNLEN */
int rccIsASCII(const char *str);
size_t rccStringSizedGetChars(const char *str, size_t size);
diff --git a/src/rccxml.c b/src/rccxml.c
index 03230d0..1db5788 100644
--- a/src/rccxml.c
+++ b/src/rccxml.c
@@ -340,7 +340,12 @@ int rccSave(rcc_context ctx, const char *name) {
sprintf(config,"%s/.rcc/%s.xml",rcc_home_dir,name);
fd = open(config, O_CREAT|O_RDWR,00644);
if (fd == -1) goto clear;
+
+#if defined(HAVE_FLOCK)
flock(fd, LOCK_EX);
+#elif defined(HAVE_LOCKF)
+ lockf(fd, F_LOCK, 1);
+#endif
if ((!fstat(fd, &st))&&(st.st_size)) {
doc = xmlReadFd(fd, config, NULL, 0);
@@ -463,7 +468,13 @@ clear:
xmlFreeDoc(doc);
}
fsync(fd);
- flock(fd, LOCK_UN);
+
+#if defined(HAVE_FLOCK)
+ flock(fd, LOCK_UN);
+#elif defined(HAVE_LOCKF)
+ lockf(fd, F_ULOCK, 1);
+#endif
+
close(fd);
}
free(config);
@@ -516,11 +527,22 @@ int rccLoad(rcc_context ctx, const char *name) {
free(config);
if (fd != -1) {
+#if defined(HAVE_FLOCK)
flock(fd, LOCK_EX);
+#elif defined(HAVE_LOCKF)
+ lockf(fd, F_LOCK, 1);
+#endif
+
if ((!fstat(fd, &st))&&(st.st_size)) {
doc = xmlReadFd(fd, name, NULL, 0);
}
+
+#if defined(HAVE_FLOCK)
flock(fd, LOCK_UN);
+#elif defined(HAVE_LOCKF)
+ lockf(fd, F_ULOCK, 1);
+#endif
+
close(fd);
if (doc) {
@@ -533,11 +555,22 @@ int rccLoad(rcc_context ctx, const char *name) {
}
if (sysfd != -1) {
+#if defined(HAVE_FLOCK)
flock(sysfd, LOCK_EX);
+#elif defined(HAVE_LOCKF)
+ lockf(sysfd, F_LOCK, 1);
+#endif
+
if ((!fstat(sysfd, &st))&&(st.st_size)) {
sysdoc = xmlReadFd(sysfd, name, NULL, 0);
}
+
+#if defined(HAVE_FLOCK)
flock(sysfd, LOCK_UN);
+#elif defined(HAVE_LOCKF)
+ lockf(sysfd, F_ULOCK, 1);
+#endif
+
close(sysfd);
if (sysdoc) {