]> andersk Git - moira.git/blobdiff - dcm/utils.c
machine attributes changed (incomplete)
[moira.git] / dcm / utils.c
index 19f8b4e5792dba6eff09820df894aa1942d50f75..db51555b7b79cd4136525f9e2baed15e6e18d583 100644 (file)
@@ -3,23 +3,28 @@
  *     $Author$
  *     $Header$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
  * 
  *     Utility functions used by the DCM.
+ *
+ *  (c) Copyright 1987, 1988 by the Massachusetts Institute of Technology.
+ *  For copying and distribution information, please see the file
+ *  <mit-copyright.h>.
  */
 
 #ifndef lint
 static char *rcsid_utils_c = "$Header$";
 #endif lint
 
+#include <mit-copyright.h>
 #include <stdio.h>
 #include <strings.h>
+#include <errno.h>
 #include <varargs.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/file.h>
-#include <zephyr/zephyr.h>
-#include <sms.h>
+#include <moira.h>
+#include <moira_site.h>
 #include "dcm.h"
 
 
@@ -86,14 +91,14 @@ char *tkt_string()
 }
 
 
-int maybe_lock_update(dir, host, service, exclusive)
-char *dir, *host, *service;
+int maybe_lock_update(host, service, exclusive)
+char *host, *service;
 int exclusive;
 {
     char lock[BUFSIZ];
     int fd;
 
-    sprintf(lock, "%s/dcm/locks/%s.%s", dir, host, service);
+    sprintf(lock, "%s/%s.%s", LOCK_DIR, host, service);
     if ((fd = open(lock, O_TRUNC |  O_CREAT, 0)) < 0)
       com_err(whoami, errno, ": maybe_lock_update: opening %s", lock);
     else if (flock(fd, (exclusive ? LOCK_EX : LOCK_SH) | LOCK_NB) != 0) {
@@ -108,3 +113,21 @@ int exclusive;
     return fd;
 }
 
+
+int mr_query_with_retry(name, argc, argv, proc, hint)
+char *name;
+int argc;
+char **argv;
+int (*proc)();
+char *hint;
+{
+    int status, tries;
+
+    for (tries = 0; tries < DEADLOCK_TRIES; tries++) {
+       status = mr_query(name, argc, argv, proc, hint);
+       if (status != MR_DEADLOCK)
+         return(status);
+       sleep(DEADLOCK_WAIT);
+    }
+    return(status);
+}
This page took 0.053915 seconds and 4 git commands to generate.