From e1580ae7d64a01efb2464cbbffb6d99cb5af1b8a Mon Sep 17 00:00:00 2001 From: marha Date: Wed, 2 Sep 2009 19:11:07 +0000 Subject: Switched to libXau-1.0.5.tar.gz --- libXau/AuLock.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'libXau/AuLock.c') diff --git a/libXau/AuLock.c b/libXau/AuLock.c index 001235607..69b1fd69a 100644 --- a/libXau/AuLock.c +++ b/libXau/AuLock.c @@ -90,14 +90,28 @@ long dead) (void) close (creat_fd); } if (creat_fd != -1) { - if (link (creat_name, link_name) != -1) - return LOCK_SUCCESS; - if (errno == ENOENT) { - creat_fd = -1; /* force re-creat next time around */ - continue; - } - if (errno != EEXIST) - return LOCK_ERROR; +#ifndef X_NOT_POSIX + /* The file system may not support hard links, and pathconf should tell us that. */ + if (1 == pathconf(creat_name, _PC_LINK_MAX)) { + if (-1 == rename(creat_name, link_name)) { + /* Is this good enough? Perhaps we should retry. TEST */ + return LOCK_ERROR; + } else { + return LOCK_SUCCESS; + } + } else { +#endif + if (link (creat_name, link_name) != -1) + return LOCK_SUCCESS; + if (errno == ENOENT) { + creat_fd = -1; /* force re-creat next time around */ + continue; + } + if (errno != EEXIST) + return LOCK_ERROR; +#ifndef X_NOT_POSIX + } +#endif } (void) sleep ((unsigned) timeout); --retries; -- cgit v1.2.3