641727d6ff71482877716d038a16a629b38523dc
galt
  Mon Jul 5 23:24:00 2010 -0700
adding retries to paraFetch for greater reliability to finish unattended.  sleeps 30 seconds between retries
diff --git src/lib/net.c src/lib/net.c
index db087c1..79f2d6c 100644
--- src/lib/net.c
+++ src/lib/net.c
@@ -1397,7 +1397,7 @@
 }
 
 
-boolean parallelFetch(char *url, int numConnections, char *outPath)
+boolean parallelFetch(char *url, char *outPath, int numConnections, int numRetries)
 /* Open multiple parallel connections to URL to speed downloading */
 {
 char *origPath = outPath;
@@ -1481,6 +1481,9 @@
     return FALSE;
     }
 
+if (numRetries < 0)
+    numRetries = 0;
+
 /* what is the size of each part */
 off_t partSize = (fileSize + numConnections -1) / numConnections;
 if (fileSize == -1) 
@@ -1555,7 +1558,11 @@
 /* create paraFetchStatus right away for monitoring programs */
 writeParaFetchStatus(origPath, pcList, url, fileSize, dateString, FALSE);
 sinceLastStatus = 0;
+
+int retryCount = 0;
+
 #define SELTIMEOUT 5
+#define RETRYSLEEPTIME 30    
 while (TRUE)
     {
 
@@ -1738,8 +1745,30 @@
     else
 	{
 	warn("No data within %d seconds for %s", SELTIMEOUT, url);
+	/* Retry ? */
+	if (retryCount >= numRetries)
+	    {
 	return FALSE;
 	}
+	else
+	    {
+	    ++retryCount;
+	    /* close any open connections */
+	    for(pc = pcList; pc; pc = pc->next)
+		{
+		if (pc->sd >= 0) 
+		    {
+		    close(pc->sd);
+		    verbose(2,"closing descriptor: %d\n", pc->sd);
+		    }
+		pc->sd = -4;
+		}
+	    connOpen = 0;
+	    reOpen = 0;
+	    /* sleep for a while, maybe the server will recover */
+	    sleep(RETRYSLEEPTIME);
+	    }
+	}
 
     }