f73e7f5ce028d89c0ccb0a19268dc4c739746a79 hiram Mon Jun 21 13:44:01 2021 -0700 replacing hgBotDelayFrac with earlyBotCheck refs #23217 diff --git src/hg/hgBlat/hgBlat.c src/hg/hgBlat/hgBlat.c index c2d21ed..2f7188d 100644 --- src/hg/hgBlat/hgBlat.c +++ src/hg/hgBlat/hgBlat.c @@ -30,30 +30,34 @@ #include "portable.h" #include "portable.h" #include "dystring.h" #include "chromInfo.h" #include "net.h" #include "fuzzyFind.h" struct cart *cart; /* The user's ui state. */ struct hash *oldVars = NULL; boolean orgChange = FALSE; boolean dbChange = FALSE; boolean allGenomes = FALSE; boolean allResults = FALSE; static long enteredMainTime = 0; +/* for earlyBotCheck() function at the beginning of main() */ +#define delayFraction 0.5 /* standard penalty is 1.0 for most CGIs */ + /* this one is 0.5 */ +static boolean issueBotWarning = FALSE; struct gfResult /* Detailed gfServer results, this is a span of several nearby tiles, minimum 2 for dna. */ { struct gfResult *next; /* have to multiply translated coordinates by 3 */ int qStart; /* Query Start Coordinate */ int qEnd; /* Query End Coordinate */ char *chrom; /* Target Chrom Name */ int tStart; /* Target Start Coordinate */ int tEnd; /* Target End Coordinate */ int numHits; /* number of tile hits, minimum 2 for dna */ char tStrand; /* + or - Target Strand used with prot, rnax, dnax */ int tFrame; /* Target Frame 0,1,2 (mostly ignorable?) used with prot, rnax, dnax */ int qFrame; /* Query Frame 0,1,2 (mostly ignorable?) used with rnax, dnax*/ @@ -1643,32 +1647,40 @@ findGenomeParams(conn, serve); int minLucky = (serve->minMatch * serve->stepSize + (serve->tileSize - serve->stepSize)) * xlat; minSuggested = max(minMatchShown,minLucky); } int seqNumber = 0; /* Loop through each sequence. */ for (seq = seqList; seq != NULL; seq = seq->next) { printf(" "); fflush(stdout); /* prevent apache cgi timeout by outputting something */ oneSize = realSeqSize(seq, !isTx); // Impose half the usual bot delay per sequence - if (dbCount == 0) - hgBotDelayFrac(0.5); +/* used to have hgBotDelayFrac(0.5) here, replaced with earlyBotCheck() + * at the beginning of main() to output message here if in delay time + * 2021-06-21 - Hiram + */ + if (dbCount == 0 && issueBotWarning) + { + char *ip = getenv("REMOTE_ADDR"); + botDelayMessage(ip, botDelayMillis); + } + if (++seqCount > maxSeqCount) { warn("More than %d input sequences, stopping at %s<br>(see also: cgi-bin/hg.conf hgBlat.maxSequenceCount setting).", maxSeqCount, seq->name); break; } if (oneSize > maxSingleSize) { warn("Sequence %s is %d letters long (max is %d), skipping", seq->name, oneSize, maxSingleSize); continue; } if (oneSize < minSuggested) { warn("Warning: Sequence %s is only %d letters long (%d is the recommended minimum)", @@ -2340,25 +2352,27 @@ cartWebEnd(); } else blatSeq(skipLeadingSpaces(userSeq), organism, db, 0); } } /* Null terminated list of CGI Variables we don't want to save * permanently. */ char *excludeVars[] = {"Submit", "submit", "Clear", "Lucky", "type", "userSeq", "seqFile", "showPage", "changeInfo", NULL}; int main(int argc, char *argv[]) /* Process command line. */ { enteredMainTime = clock1000(); +/* 0, 0, == use default 10 second for warning, 20 second for immediate exit */ +issueBotWarning = earlyBotCheck(enteredMainTime, "hgBlat", delayFraction, 0, 0, "html"); oldVars = hashNew(10); cgiSpoof(&argc, argv); /* org has precedence over db when changeInfo='orgChange' */ cartEmptyShell(doMiddle, hUserCookie(), excludeVars, oldVars); cgiExitTime("hgBlat", enteredMainTime); return 0; }