a47f57d008f2db28a7b140ece87cbcfb8e8a5c0c hiram Thu Sep 12 14:18:19 2019 -0700 expand earlyBotCheck to manage two types of outputs, recognize defaults, and adding hgGateway to the game refs #23217 diff --git src/hg/hgGateway/hgGateway.c src/hg/hgGateway/hgGateway.c index e809064..859d427 100644 --- src/hg/hgGateway/hgGateway.c +++ src/hg/hgGateway/hgGateway.c @@ -16,35 +16,38 @@ #include "errCatch.h" #include "googleAnalytics.h" #include "hCommon.h" #include "hgConfig.h" #include "hdb.h" #include "htmshell.h" #include "hubConnect.h" #include "hui.h" #include "jsHelper.h" #include "jsonParse.h" #include "obscure.h" // for readInGulp #include "regexHelper.h" #include "suggest.h" #include "trackHub.h" #include "web.h" +#include "botDelay.h" /* Global Variables */ struct cart *cart = NULL; /* CGI and other variables */ struct hash *oldVars = NULL; /* Old contents of cart before it was updated by CGI */ +static boolean issueBotWarning = FALSE; + #define SEARCH_TERM "hggw_term" static char *maybeGetDescriptionText(char *db) /* Slurp the description.html file for db into a string (if possible, don't die if * we can't read it) and return it. */ { struct errCatch *errCatch = errCatchNew(); char *descText = NULL; if (errCatchStart(errCatch)) { char *htmlPath = hHtmlPath(db); if (isNotEmpty(htmlPath)) descText = udcFileReadAll(htmlPath, NULL, 0, NULL); } errCatchEnd(errCatch); @@ -864,27 +867,34 @@ writeDbDbMatch(jw, match, term, category); // Write out assembly hub matches, if any. writeAssemblyHubMatches(jw, aHubMatchList); jsonWriteListEnd(jw); puts(jw->dy->string); jsonWriteFree(&jw); } int main(int argc, char *argv[]) /* Process CGI / command line. */ { /* Null terminated list of CGI Variables we don't want to save * permanently. */ char *excludeVars[] = {SEARCH_TERM, CARTJSON_COMMAND, NULL,}; cgiSpoof(&argc, argv); +long enteredMainTime = clock1000(); if (cgiOptionalString(SEARCH_TERM)) + { + /* less bottleneck penalty for this operation, same as hgTracks */ +#define delayFraction 0.25 + issueBotWarning = earlyBotCheck(enteredMainTime, "hgGateway", delayFraction, 0, 0, "json"); // Skip the cart for speedy searches lookupTerm(); + } else { - long enteredMainTime = clock1000(); + /* standard default bottleneck penalty for this operation */ + issueBotWarning = earlyBotCheck(enteredMainTime, "hgGateway", 0.0, 0, 0, "html"); oldVars = hashNew(10); cartEmptyShellNoContent(doMiddle, hUserCookie(), excludeVars, oldVars); cgiExitTime("hgGateway", enteredMainTime); } return 0; }