096528b1c7dae05d4e1b8adfc23f9b97a0e24cae galt Mon Aug 12 15:23:58 2019 -0700 make blatServersCheck able to continue checking other servers after a connection failure, caused by a gfServer being dowm. diff --git src/hg/utils/blatServersCheck/blatServersCheck.c src/hg/utils/blatServersCheck/blatServersCheck.c index 354c44f..fce79e2 100644 --- src/hg/utils/blatServersCheck/blatServersCheck.c +++ src/hg/utils/blatServersCheck/blatServersCheck.c @@ -57,95 +57,102 @@ }; char *getCfgOption(char *config, char *setting) /* get setting for specified config */ { char temp[256]; safef(temp, sizeof(temp), "%s.%s", config, setting); char *value = cfgOption(temp); if (!value) errAbort("setting %s not found!",temp); return value; } int statusServer(char *hostName, char *portName, boolean isTrans, struct hash *versionHash) /* Send status message to server arnd report result. - * Returns -1 for error reading string. - * Returns -2 for type mismatch. - * Returns -3 for host mismatch. - * Returns -4 for port mismatch. + * Returns -1 for connection error. + * Returns -2 for error reading string. + * Returns -3 for type mismatch. + * Returns -4 for host mismatch. + * Returns -5 for port mismatch. */ { char buf[256]; int sd = 0; int ret = 0; /* Put together command. */ -sd = netMustConnectTo(hostName, portName); +sd = gfMayConnect(hostName, portName); +if (sd == -1) + { + warn("Error connecting to %s:%s", hostName, portName); + return -1; + } + sprintf(buf, "%sstatus", gfSignature()); mustWriteFd(sd, buf, strlen(buf)); for (;;) { if (netGetString(sd, buf) == NULL) { warn("Error reading status information from %s:%s", hostName, portName); - ret = -1; + ret = -2; // error reading response break; } if (sameString(buf, "end")) { break; } else { verbose(2, "%s\n", buf); if (startsWith("version ", buf)) { char *hashKey = buf+strlen("version "); hashIncInt(versionHash, hashKey); // count how many with this version } if (startsWith("type ", buf)) { if (sameString(buf, "type translated") && !isTrans) { warn("type mismatch: gfServer says type translated but db says isTrans==0"); - ret = -2; // type mismatch + ret = -3; // type mismatch break; } if (sameString(buf, "type nucleotide") && isTrans) { warn("type mismatch: gfServer says type nucleotide but db says isTrans==1"); - ret = -2; // type mismatch + ret = -3; // type mismatch break; } } if (startsWith("host ", buf)) { if (!sameString(buf+strlen("host "), hostName)) { warn("host mismatch: gfServer says %s but db says db=%s", buf, hostName); - ret = -3; // host mismatch + ret = -4; // host mismatch break; } } if (startsWith("port ", buf)) { if (!sameString(buf+strlen("port "), portName)) { warn("port mismatch: gfServer says %s but db says port=%s", buf, portName); - ret = -4; // port mismatch // probably never happens. + ret = -5; // port mismatch // probably never happens. break; } } } } close(sd); return(ret); } int getFileList(char *hostName, char *portName, char *db) /* Get and display input file list. */ { char buf[256]; int sd = 0; @@ -222,31 +229,35 @@ int errCount = 0; sqlSafef(query,sizeof(query), "select db, host, port, isTrans from %s", blatServersTableName); sr = sqlGetResult(conn, query); while ((row = sqlNextRow(sr)) != NULL) { char *db = row[0]; char *host = row[1]; char *portStr = row[2]; unsigned int port = sqlUnsigned(portStr); unsigned int trans = sqlUnsigned(row[3]); boolean isTrans = (trans == 1); int res = statusServer(host, portStr, isTrans, versionHash); - int res2 = getFileList(host, portStr, db); + int res2 = 0; + if (res != -1) // if not a connection error, proceed. + { + res2 = getFileList(host, portStr, db); + } safef(hashKey, sizeof hashKey, "%s:%s", host, portStr); struct hashEl *hel = hashLookup(hash, hashKey); if (hel == NULL) { hashAdd(hash, hashKey, NULL); } else { warn("duplicate host:port %s found", hashKey); } if ((res != 0) || (res2 != 0) || (hel != NULL)) { ++errCount; verbose(1, "db=%s host=%s port=%d isTrans=%d res=%d res2=%d\n\n", db, host, port, trans, res, res2);