summaryrefslogtreecommitdiffstats
path: root/common/dotlock.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de>2012-01-03 17:32:41 +0100
committerMarcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de>2012-01-03 17:32:41 +0100
commitff2095ad7b4be7eaf9468b6ef39fd979527ecc4f (patch)
treed56fbb88ba78efa93a120eff511cdda585433389 /common/dotlock.c
parentFix compiler warnings. (diff)
downloadgnupg2-ff2095ad7b4be7eaf9468b6ef39fd979527ecc4f.tar.xz
gnupg2-ff2095ad7b4be7eaf9468b6ef39fd979527ecc4f.zip
Revert last change, add comment about link() return values.
* common/dotlock.c (use_hardlinks_p, dotlock_take_unix): Do not check return value of link().
Diffstat (limited to 'common/dotlock.c')
-rw-r--r--common/dotlock.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/common/dotlock.c b/common/dotlock.c
index 58a3d0f2a..5e17e64c6 100644
--- a/common/dotlock.c
+++ b/common/dotlock.c
@@ -583,21 +583,17 @@ use_hardlinks_p (const char *tname)
strcpy (lname, tname);
strcat (lname, "x");
- res = link (tname, lname);
- if (res < 0)
- res = -1;
- else
- {
- if (stat (tname, &sb))
- res = -1; /* Ooops. */
- else if (sb.st_nlink == nlink + 1)
- res = 0; /* Yeah, hardlinks are supported. */
- else
- res = 1; /* No hardlink support. */
+ /* We ignore the return value of link() because it is unreliable. */
+ (void) link (tname, lname);
- unlink (lname);
- }
+ if (stat (tname, &sb))
+ res = -1; /* Ooops. */
+ else if (sb.st_nlink == nlink + 1)
+ res = 0; /* Yeah, hardlinks are supported. */
+ else
+ res = 1; /* No hardlink support. */
+ unlink (lname);
jnlib_free (lname);
return res;
}
@@ -953,7 +949,6 @@ dotlock_destroy (dotlock_t h)
static int
dotlock_take_unix (dotlock_t h, long timeout)
{
- int res;
int wtime = 0;
int sumtime = 0;
int pid;
@@ -1010,13 +1005,8 @@ dotlock_take_unix (dotlock_t h, long timeout)
{
struct stat sb;
- res = link (h->tname, h->lockname);
- if (res < 0)
- {
- my_error_1 ("lock not made: Oops: link of tmp file failed: %s\n",
- strerror (errno));
- return -1;
- }
+ /* We ignore the return value of link() because it is unreliable. */
+ (void) link (h->tname, h->lockname);
if (stat (h->tname, &sb))
{