diff options
author | Not Zed <NotZed@HelixCode.com> | 2000-11-16 16:36:39 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-11-16 16:36:39 +0800 |
commit | d39149c5797d79e902621585554985132c1e445d (patch) | |
tree | 5319382fa77e77f4b80f78d3ff7c5f31b69b7802 /camel/camel-lock.c | |
parent | c484e227fd338b26e4bf1b075dc8a7701d77a120 (diff) | |
download | gsoc2013-evolution-d39149c5797d79e902621585554985132c1e445d.tar gsoc2013-evolution-d39149c5797d79e902621585554985132c1e445d.tar.gz gsoc2013-evolution-d39149c5797d79e902621585554985132c1e445d.tar.bz2 gsoc2013-evolution-d39149c5797d79e902621585554985132c1e445d.tar.lz gsoc2013-evolution-d39149c5797d79e902621585554985132c1e445d.tar.xz gsoc2013-evolution-d39149c5797d79e902621585554985132c1e445d.tar.zst gsoc2013-evolution-d39149c5797d79e902621585554985132c1e445d.zip |
New file - utility functions for locking using different strategies and/or
2000-11-16 Not Zed <NotZed@HelixCode.com>
* camel-lock.c: New file - utility functions for locking using
different strategies and/or for locking folders safely.
* Makefile.am (libcamel_la_SOURCES): Adde camel-lock.[ch]
svn path=/trunk/; revision=6590
Diffstat (limited to 'camel/camel-lock.c')
-rw-r--r-- | camel/camel-lock.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/camel/camel-lock.c b/camel/camel-lock.c index d6c3ad9312..f14e4ece5d 100644 --- a/camel/camel-lock.c +++ b/camel/camel-lock.c @@ -22,16 +22,20 @@ #include <config.h> -/* need configure checks here */ +/* need configure checks or some configurable thingy here */ #define USE_DOT #define USE_FCNTL #define USE_FLOCK +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + #include <sys/stat.h> #include <unistd.h> #include <errno.h> #include <alloca.h> -#include <string.h> +#include <time.h> #ifdef USE_DOT #include <sys/types.h> @@ -51,7 +55,7 @@ #include "camel-lock.h" /* dunno where this fucking thing is got from */ -/*#define _(x) (x)*/ +#define _(x) (x) #define d(x) (printf("%s(%d): ", __FILE__, __LINE__),(x)) @@ -71,7 +75,7 @@ camel_lock_dot(const char *path, CamelException *ex) #ifdef USE_DOT char *locktmp, *lock; int retry = 0; - int fdtmp, fd; + int fdtmp; struct stat st; /* TODO: Is there a reliable way to refresh the lock, if we're still busy with it? @@ -133,7 +137,7 @@ camel_lock_dot(const char *path, CamelException *ex) /* check for stale lock, kill it */ if (stat(lock, &st) == 0) { time_t now = time(0); - d(printf("There is an existing lock %d seconds old\n", now-st.st_ctime)); + d(printf("There is an existing lock %ld seconds old\n", now-st.st_ctime)); if (st.st_ctime < now - CAMEL_LOCK_DOT_STALE) { d(printf("Removing it now\n")); unlink(lock); |