[distcc] hpux locking

Martin Pool mbp at sourcefrog.net
Fri Feb 28 22:01:44 GMT 2003


On 28 Feb 2003, Tom Matelich <tmatelich at zetec.com> wrote:
> Well, I've checked permissions again.

It turns out that HP-UX returns EACCES for lock contention, which is
allowed by SUSv3.  This patch against 1.2.2 should fix your problems,
and possibly Cygwin too.

Thanks for helping debug it.


Index: lock.c
===================================================================
RCS file: /data/cvs/distcc/src/lock.c,v
retrieving revision 1.23
diff -u -u -p -r1.23 lock.c
--- lock.c	25 Feb 2003 00:28:56 -0000	1.23
+++ lock.c	28 Feb 2003 22:04:55 -0000
@@ -28,7 +28,7 @@
 /**
  * @file
  *
- * Manage lockfiles.
+ * @brief Manage lockfiles.
  *
  * distcc uses a simple disk-based lockfile system to keep track of how many
  * jobs are queued on various machines.  These locks might be used for
@@ -102,7 +102,7 @@ static char * dcc_make_lock_filename(con
     if (host->mode == DCC_MODE_LOCAL) {
         asprintf(&buf, "%s/lock_%s_localhost_%d", tempdir, lockname, iter);
     } else if (host->mode == DCC_MODE_TCP) {
-        asprintf(&buf, "%s/lock_%s_tcp_%s:%d_%d", tempdir, lockname, host->hostname,
+        asprintf(&buf, "%s/lock_%s_tcp_%s_%d_%d", tempdir, lockname, host->hostname,
                  host->port, iter);
     } else if (host->mode == DCC_MODE_SSH) {
         asprintf(&buf, "%s/lock_%s_ssh_%s_%d", tempdir, lockname, host->hostname, iter);
@@ -121,8 +121,8 @@ static char * dcc_make_lock_filename(con
  * Get an exclusive, non-blocking lock on a file using whatever method
  * is available on this system.
  *
- * @return 0 if we got the lock; -1 with EAGAIN if the file is already
- * locked.
+ * @retval 0 if we got the lock
+ * @retval -1 with EAGAIN if the file is already locked.
  **/
 static int sys_lock(int fd, int block)
 {
@@ -204,7 +204,8 @@ int dcc_lock_host(const char *lockname,
     }        
 
     if (sys_lock(*lock_fd, block) == 0) {
-        rs_trace("locked %s", fname);
+        /* TODO: Print better readable form of hostdef. */
+        rs_trace("got %s lock on %s slot %d", lockname, host->hostname, slot);
         free(fname);
         return 0;
     } else {
@@ -212,9 +213,10 @@ int dcc_lock_host(const char *lockname,
 #ifdef EWOULDBLOCK
         case EWOULDBLOCK:
 #endif
-#if defined(EAGAIN) && EAGAIN != EWOULDBLOCK
+#ifdef EAGAIN
         case EAGAIN:
 #endif
+        case EACCES: /* HP-UX gives this for exclusion */
             rs_trace("%s is busy", fname);
             ret = EXIT_BUSY;
             break;
@@ -228,7 +230,4 @@ int dcc_lock_host(const char *lockname,
         free(fname);
         return ret;
     }
-
-    /* TODO: Print better readable form of hostdef. */
-    rs_trace("got %s lock on %s slot %d", lockname, host->hostname, slot);
 }


-- 
Martin


More information about the distcc mailing list