From 55c48cdf78adf9724f7c2aba8dbf1618b8d36ef8 Mon Sep 17 00:00:00 2001
From: "Leigh B. Stoller" <stoller@flux.utah.edu>
Date: Tue, 26 Oct 2004 22:11:20 +0000
Subject: [PATCH] Oops, do something I promised to do while in DC; Add a little
 bit of retry when getting the topomap, to try and avoid transient NFS errors.
 Very silly.

Lbs
---
 tmcd/common/config/rc.topomap | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/tmcd/common/config/rc.topomap b/tmcd/common/config/rc.topomap
index 925be28398..323b0a2678 100755
--- a/tmcd/common/config/rc.topomap
+++ b/tmcd/common/config/rc.topomap
@@ -132,13 +132,24 @@ sub dotopomap()
     # Copy over the topomap so that it is locally resident. We will eventually
     # get this via a tarfile instead of NFS.
     #
-    my $topomap = "/proj/$pid/exp/$eid/tbdata/topomap";
+    my $topomap = "/proj/$pid/exp/$eid/tbdata/topomap.gz";
+    my $tempmap = "/tmp/topomap.gz";
+
+    #
+    # Try a couple of times to get the file cause of NFS sillyness.
+    # Should probably have our own version of cp that retries at the block
+    # level?
+    # 
+    for (my $i = 0; $i < 5; $i++) {
+	last
+	    if (system("cp -fp $topomap $tempmap") == 0);
+	unlink("$tempmap");
+    }
     
-    if (-e "${topomap}.gz") {
-	system("cat ${topomap}.gz | gunzip > " . TMTOPOMAP());
+    if (-e ${tempmap}) {
+	system("cat ${tempmap} | gunzip > " . TMTOPOMAP());
     }
-    elsif (-e $topomap) {
-	system("cp -fp $topomap ". TMTOPOMAP());
+    else {
+	fatal("Could not copy over $topomap");
     }
-   
 }
-- 
GitLab