9ae36bf63931b4a9d8a5a66e0d4696ead3a86eac galt Tue Mar 5 15:46:24 2019 -0800 Fixing race condition where background is slow starting up. Found by Daniel. diff --git src/hg/hgSession/backup.c src/hg/hgSession/backup.c index ce371aa..cb79263 100644 --- src/hg/hgSession/backup.c +++ src/hg/hgSession/backup.c @@ -72,30 +72,38 @@ void htmlClose() /* Close down html format page. */ { popWarnHandler(); cartWebEnd(); } // ------------------------------------------ void getBackgroundStatus(char *url) /* fetch status as the latest complete html block available. * fetch progress info instead if background proc still running. */ { char *html = NULL; +int waited = 0; +// sometimes the background process is a little slow, +// we can wait up to 30 seconds for it. +while ((fileSize(url)==0) && (waited < 30)) + { + sleep(1); + ++waited; + } if (fileSize(url)==0) { htmlOpen("Background Status"); errAbort("No output found. Expecting output in [%s].", url); htmlClose(); return; } // get the pid and see if it is still running char pidName[1024]; safef(pidName, sizeof pidName, "%s.pid", url); FILE *pidF = mustOpen(pidName, "r"); long pid = 0; fscanf(pidF, "%ld", &pid); carefulClose(&pidF);