a18cdd4441c5dfa23fd9112d12e01f1123568519
galt
  Mon Nov 5 13:13:03 2012 -0800
removing the new connFailures capability.  it is difficult to distinguish failing sites from struggling sites with this approach -- so leave it out for now.
diff --git src/lib/net.c src/lib/net.c
index 518854e..5de7ef0 100644
--- src/lib/net.c
+++ src/lib/net.c
@@ -10,112 +10,32 @@
 #include <sys/time.h>
 #include <utime.h>
 #include <pthread.h>
 #include "internet.h"
 #include "errabort.h"
 #include "hash.h"
 #include "net.h"
 #include "linefile.h"
 #include "base64.h"
 #include "cheapcgi.h"
 #include "https.h"
 #include "sqlNum.h"
 #include "obscure.h"
 
 /* Brought errno in to get more useful error messages */
-
 extern int errno;
 
-/* when there are many cts, threads, hubtracks, etc
- * need a quick way to remember failures to not repeat them */
-
-struct connFailure
-/* remember connect failure */
-    {
-    char *hostName;       /* hostName */
-    int port;             /* port */
-    char *errorString;    /* error message to report next time */
-    };
-
-#define MAXCONNFAILURES 1024
-static struct connFailure connFailures[MAXCONNFAILURES];
-static int numConnFailures = 0;
-static pthread_mutex_t cfMutex = PTHREAD_MUTEX_INITIALIZER;
-static boolean connFailuresEnabled = FALSE;
-
-void setConnFailuresEnabled(boolean val)
-/* Turn on or off the connFailures feature */
-{
-connFailuresEnabled = val;
-}
-
-boolean checkConnFailure(char *hostName, int port, char **pErrStr)
-/* check if this hostName:port has already had failure
- *  which can save time and avoid more timeouts */
-{
-if (!connFailuresEnabled)
-    return FALSE;
-pthread_mutex_lock( &cfMutex );
-int imax = numConnFailures;
-pthread_mutex_unlock( &cfMutex );
-struct connFailure *cf = connFailures;
-int i;
-boolean result = FALSE;
-for(i=0;i<imax;++i)
-    {
-    if (sameString(cf->hostName, hostName) && cf->port == port)
-	{
-	if (pErrStr)
-	    {
-	    *pErrStr = cf->errorString;
-	    }
-	result = TRUE;
-	break;
-	}
-    ++cf;
-    }
-return result;
-}
-
-
-void addConnFailure(char *hostName, int port, char *format, ...)
-/* add a failure to connFailures[]
- *  which can save time and avoid more timeouts */
-{
-if (!connFailuresEnabled)
-    return;
-char errorString[1024];
-va_list args;
-vasafef(errorString, sizeof errorString, format, args);
-va_end(args);
-if (!checkConnFailure(hostName,port,NULL))
-    {
-    pthread_mutex_lock( &cfMutex );
-    if (numConnFailures < MAXCONNFAILURES)
-	{
-	struct connFailure *cf = connFailures + numConnFailures;
-	cf->hostName = cloneString(hostName);
-	cf->port = port;
-	cf->errorString = cloneString(errorString);
-	numConnFailures++;
-	}
-    pthread_mutex_unlock( &cfMutex );
-    }
-}
-
-
-
 static int netStreamSocket()
 /* Create a TCP/IP streaming socket.  Complain and return something
  * negative if can't */
 {
 int sd = socket(AF_INET, SOCK_STREAM, 0);
 if (sd < 0)
     warn("Couldn't make AF_INET socket.");
 return sd;
 }
 
 static int setSocketNonBlocking(int sd, boolean set)
 /* Use socket control flags to set O_NONBLOCK if set==TRUE,
  * or clear it if set==FALSE.
  * Return -1 if there are any errors, 0 if successful. i
  * Also closes sd if error. */
@@ -153,37 +73,30 @@
 a.tv_usec -= b.tv_usec;
 a.tv_sec -= b.tv_sec;
 return a;
 }
 
 static int netConnectWithTimeout(char *hostName, int port, long msTimeout)
 /* In order to avoid a very long default timeout (several minutes) for hosts that will
  * not answer the port, we are forced to connect non-blocking.
  * After the connection has been established, we return to blocking mode. */
 {
 int sd;
 struct sockaddr_in sai;		/* Some system socket info. */
 int res;
 fd_set mySet;
 
-char *errorString = NULL;
-if (checkConnFailure(hostName, port, &errorString))
-    {
-    warn("%s", errorString);
-    return -1;
-    }
-
 if (hostName == NULL)
     {
     warn("NULL hostName in netConnect");
     return -1;
     }
 if (!internetFillInAddress(hostName, port, &sai))
     return -1;
 if ((sd = netStreamSocket()) < 0)
     return sd;
 
 // Set socket to nonblocking so we can manage our own timeout time.
 if (setSocketNonBlocking(sd, TRUE) < 0)
     {
     close(sd);
     return -1;
@@ -235,42 +148,37 @@
 		// Socket selected for write when it is ready
 		int valOpt;
 		socklen_t lon;
                 // But check the socket for any errors
                 lon = sizeof(valOpt);
                 if (getsockopt(sd, SOL_SOCKET, SO_ERROR, (void*) (&valOpt), &lon) < 0)
                     {
                     warn("Error in getsockopt() %d - %s", errno, strerror(errno));
                     close(sd);
                     return -1;
                     }
                 // Check the value returned...
                 if (valOpt)
                     {
                     warn("Error in TCP non-blocking connect() %d - %s", valOpt, strerror(valOpt));
-		    if (valOpt == ETIMEDOUT)
-    			addConnFailure(hostName, port,
-			 "Error in TCP non-blocking connect() %d - %s", valOpt, strerror(valOpt));
                     close(sd);
                     return -1;
                     }
 		break;
 		}
 	    else
 		{
-		addConnFailure(hostName, port,
-		     "TCP non-blocking connect() to %s timed-out in select() after %ld milliseconds - Cancelling!", hostName, msTimeout);
 		warn("TCP non-blocking connect() to %s timed-out in select() after %ld milliseconds - Cancelling!", hostName, msTimeout);
 		close(sd);
 		return -1;
 		}
 	    }
 	}
     else
 	{
 	warn("TCP non-blocking connect() error %d - %s", errno, strerror(errno));
 	close(sd);
 	return -1;
 	}
     }
 
 // Set to blocking mode again