diff options
author | Halton Huo <halton.huo@sun.com> | 2007-12-07 06:38:54 +0000 |
---|---|---|
committer | Halton Huo <haltonhuo@src.gnome.org> | 2007-12-07 06:38:54 +0000 |
commit | 0daa1bb34dd6f7a39e5d00d8ff78b42d632eacc9 (patch) | |
tree | 00ce1550269d48f7e2b3a20f4976c801316d044e /pk | |
parent | 98b547945e30e3f504c6302f18a884f057b61807 (diff) |
Fix bug #501996 check flock and timegm existence. Implement flock if flock
2007-12-06 Halton Huo <halton.huo@sun.com>
Fix bug #501996
* configure.in: check flock and timegm existence.
* pk/gkr-pk-index.c: (flock): Implement flock if flock not found.
* pkix/gkr-pkix-asn1.c: (timegm): Implement timegm if timegm not found.
svn path=/trunk/; revision=954
Diffstat (limited to 'pk')
-rw-r--r-- | pk/gkr-pk-index.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/pk/gkr-pk-index.c b/pk/gkr-pk-index.c index bf36d568..decc0067 100644 --- a/pk/gkr-pk-index.c +++ b/pk/gkr-pk-index.c @@ -68,6 +68,39 @@ static GQuark no_location = 0; * HELPERS */ +#ifndef HAVE_FLOCK +#define LOCK_SH 1 +#define LOCK_EX 2 +#define LOCK_NB 4 +#define LOCK_UN 8 + +static int flock(int fd, int operation) +{ + struct flock flock; + + switch (operation & ~LOCK_NB) { + case LOCK_SH: + flock.l_type = F_RDLCK; + break; + case LOCK_EX: + flock.l_type = F_WRLCK; + break; + case LOCK_UN: + flock.l_type = F_UNLCK; + break; + default: + errno = EINVAL; + return -1; + } + + flock.l_whence = 0; + flock.l_start = 0; + flock.l_len = 0; + + return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &flock); +} +#endif //NOT_HAVE_FLOCK + static void free_mtime (gpointer v) { |