b973e754cafbb53bcb970d65e2c8e0915c6aa454
hiram
  Mon Sep 27 14:57:29 2021 -0700
convert hgPhyloPlace to earlyBotExit and remove dead botDelay code refs #28173

diff --git src/hg/lib/botDelay.c src/hg/lib/botDelay.c
index 6086423..e2de763 100644
--- src/hg/lib/botDelay.c
+++ src/hg/lib/botDelay.c
@@ -100,126 +100,59 @@
 return user;
 }
 
 char *getBotCheckString(char *ip, double fraction)
 /* compose "user.ip fraction" string for bot check */
 {
 char *user = getCookieUser();
 char *botCheckString = needMem(256);
 if (user)
   safef(botCheckString, 256, "%s.%s %f", user, ip, fraction);
 else
   safef(botCheckString, 256, "%s %f", ip, fraction);
 return botCheckString;
 }
 
-void botDelayCgi(char *host, int port, boolean noWarn, double fraction)
-/* Connect with bottleneck server and sleep the
- * amount it suggests for IP address calling CGI script,
- * after imposing the specified fraction of the access penalty. */
-{
-int millis;
-char *ip = getenv("REMOTE_ADDR");
-if (ip != NULL)
-    {
-    char *botCheckString = getBotCheckString(ip, fraction);
-    millis = botDelayTime(host, port, botCheckString);
-    freeMem(botCheckString);
-    if (millis > 0)
-	{
-	if (millis > 10000)
-	    {
-	    if (millis > 20000)
-	        botTerminateMessage(ip, millis);
-	    else
-		{
-		if (!noWarn)
-		    botDelayMessage(ip, millis);
-		}
-	    }
-	sleep1000(millis);
-	}
-    }
-}
-
 boolean botException()
 /* check if the remote ip address is on the exceptions list */
 {
 char *exceptIps = cfgOption("bottleneck.except");
 if (exceptIps)
     {
     char *remoteAddr = getenv("REMOTE_ADDR");
     if (remoteAddr)
 	{
 	char *s = exceptIps;
 	boolean found = FALSE;
 	while (s && !found)
 	    {
 	    char *e = strchr(s, ' ');
 	    if (e)
 		*e = 0;
 	    if (sameString(remoteAddr, s))
 		found = TRUE;
 	    if (e)
 		*e++ = ' ';
 	    s = e;
 	    }
 	if (found)
 	    return TRUE;
 	}
     }
 return FALSE;
 }
 
-static void hgBotDelayExt(boolean noWarn, double fraction)
-/* High level bot delay call - looks up bottleneck server
- * in hg.conf. */
-{
-if (botException())
-    return;
-
-char *host = cfgOption("bottleneck.host");
-char *port = cfgOption("bottleneck.port");
-
-if (host != NULL && port != NULL)
-    botDelayCgi(host, atoi(port), noWarn, fraction);
-}
-
-void hgBotDelay()
-/* High level bot delay call - for use with regular webpage output */
-{
-hgBotDelayExt(FALSE, defaultDelayFrac);
-}
-
-void hgBotDelayFrac(double fraction)
-/* Like hgBotDelay, but imposes a fraction of the standard access penalty */
-{
-hgBotDelayExt(FALSE, fraction);
-}
-
-void hgBotDelayNoWarn()
-/* High level bot delay call without warning - for use with non-webpage outputs */
-{
-hgBotDelayExt(TRUE, defaultDelayFrac);
-}
-
-void hgBotDelayNoWarnFrac(double fraction)
-/* Like hgBotDelayNoWarn, but imposes a fraction of the standard access penalty */
-{
-hgBotDelayExt(TRUE, fraction);
-}
-
 int hgBotDelayTime()
 {
 return hgBotDelayTimeFrac(defaultDelayFrac);
 }
 
 int hgBotDelayTimeFrac(double fraction)
 /* Get suggested delay time from cgi using the standard penalty. */
 {
 char *ip = getenv("REMOTE_ADDR");
 char *host = cfgOption("bottleneck.host");
 char *port = cfgOption("bottleneck.port");
 
 int delay = 0;
 if (host != NULL && port != NULL && ip != NULL)
     {
@@ -303,31 +236,31 @@
            "<b>We cannot service requests from your IP address under</b> these "
            "conditions.  (code %d) "
            "To use the genome browser functionality from a Unix command line, "
            "please read <a href='http://genome.ucsc.edu/FAQ/FAQdownloads.html#download36'>our FAQ</a> on this topic. "
            "For further help on how to access our data from a command line, "
            "or if "
            "you think this delay is being imposed unfairly, please contact genome-www@soe.ucsc.edu."
            ,hogHost, asctime(localtime(&now)), botDelayMillis);
     puts("</body></html>");
     }
 cgiExitTime(cgiExitName, enteredMainTime);
 exit(0);
 }       /*      static void hogExit()   */
 
 boolean earlyBotCheck(long enteredMainTime, char *cgiName, double delayFrac, int warnMs, int exitMs, char *exitType)
-/* similar to botDelayCgi but for use before the CGI has started any
+/* replaces the former botDelayCgi now in use before the CGI has started any
  * output or setup the cart of done any MySQL operations.  The boolean
  * return is used later in the CGI after it has done all its setups and
  * started output so it can issue the warning.  Pass in delayFrac 0.0
  * to use the default 1.0, pass in 0 for warnMs and exitMs to use defaults,
  * and exitType is either 'html' or 'json' to do that type of exit output in
  * the case of hogExit();
  */
 {
 boolean issueWarning = FALSE;
 
 if (botException())	/* don't do this if caller is on the exception list */
     return issueWarning;
 
 if (delayFrac < 0.000001) /* passed in zero, use default */
     delayFrac = defaultDelayFrac;