82b4ffe1c64351dea31fbda82f186ce0fd30675e hiram Mon Jun 21 14:08:24 2021 -0700 replacing hgBotDelay with earlyBotCheck refs #23217 diff --git src/hg/hgPcr/hgPcr.c src/hg/hgPcr/hgPcr.c index 802ce67..8647c23 100644 --- src/hg/hgPcr/hgPcr.c +++ src/hg/hgPcr/hgPcr.c @@ -24,30 +24,34 @@ #include "dbDb.h" #include "blatServers.h" #include "targetDb.h" #include "pcrResult.h" #include "trashDir.h" #include "web.h" #include "botDelay.h" #include "oligoTm.h" #include "trackHub.h" #include "hubConnect.h" struct cart *cart; /* The user's ui state. */ struct hash *oldVars = NULL; +/* for earlyBotCheck() function at the beginning of main() */ +#define delayFraction 1.0 /* standard penalty for most CGIs */ +static boolean issueBotWarning = FALSE; + void usage() /* Explain usage and exit. */ { errAbort( "hgPcr - In-silico PCR CGI for UCSC\n" "usage:\n" " hgPcr XXX\n" "options:\n" " -xxx=XXX\n" ); } struct pcrServer /* Information on a server running on genomic assembly sequence. */ { @@ -633,31 +637,40 @@ { printf("No matches to %s %s in %s", gpi->fPrimer, gpi->rPrimer, server->targetDb->description); } gfDisconnect(&conn); } boolean doPcr(struct pcrServer *server, struct targetPcrServer *targetServer, char *fPrimer, char *rPrimer, int maxSize, int minPerfect, int minGood, boolean flipReverse) /* Do the PCR, and show results. */ { struct errCatch *errCatch = errCatchNew(); boolean ok = FALSE; -hgBotDelay(); +/* used to have hgBotDelay() here, replaced with earlyBotCheck() + * at the beginning of main() to output message here if in delay time + * 2021-06-21 - Hiram + */ +if (issueBotWarning) + { + char *ip = getenv("REMOTE_ADDR"); + botDelayMessage(ip, botDelayMillis); + } + if (flipReverse) reverseComplement(rPrimer, strlen(rPrimer)); if (errCatchStart(errCatch)) { struct gfPcrInput *gpi; AllocVar(gpi); gpi->fPrimer = fPrimer; gpi->rPrimer = rPrimer; if (server != NULL) doQuery(server, gpi, maxSize, minPerfect, minGood); if (targetServer != NULL) doTargetQuery(targetServer, gpi, maxSize, minPerfect, minGood); ok = TRUE; } @@ -738,22 +751,24 @@ { cart = theCart; dnaUtilOpen(); cartWebStart(cart, NULL, "UCSC In-Silico PCR"); dispatch(); cartWebEnd(); } char *excludeVars[] = {"Submit", "submit", "wp_f", "wp_r", "wp_showPage", NULL}; int main(int argc, char *argv[]) /* Process command line. */ { long enteredMainTime = clock1000(); +/* 0, 0, == use default 10 second for warning, 20 second for immediate exit */ +issueBotWarning = earlyBotCheck(enteredMainTime, "hgPcr", delayFraction, 0, 0, "html"); oldVars = hashNew(10); cgiSpoof(&argc, argv); cartEmptyShell(doMiddle, hUserCookie(), excludeVars, oldVars); cgiExitTime("hgPcr", enteredMainTime); return 0; }