6fe66e36fae18d828825a6c551b5bb5ec05afab1 galt Thu Sep 13 11:41:17 2012 -0700 add tracking of connect-failures to hgCustom and hgTracks which may have many bigDataUrls pointing to the same failing site; also fixed a bug in the timeout handling of EINTR diff --git src/lib/https.c src/lib/https.c index 3c6cc8b..392d45a 100644 --- src/lib/https.c +++ src/lib/https.c @@ -1,28 +1,29 @@ /* Connect via https. */ #ifdef USE_SSL #include "openssl/ssl.h" #include "openssl/err.h" #include #include #include #include "common.h" #include "errabort.h" +#include "net.h" static pthread_mutex_t *mutexes = NULL; static unsigned long openssl_id_callback(void) { return ((unsigned long)pthread_self()); } static void openssl_locking_callback(int mode, int n, const char * file, int line) { if (mode & CRYPTO_LOCK) pthread_mutex_lock(&mutexes[n]); else pthread_mutex_unlock(&mutexes[n]); @@ -239,30 +240,32 @@ tv.tv_sec = 10; // timeout tv.tv_usec = 0; err = select(max(fd,params->sv[1]) + 1, &readfds, &writefds, NULL, &tv); /* Evaluate select() return code */ if (err < 0) { xerr("error during select()"); goto cleanup; } else if (err == 0) { /* Timed out - just quit */ + addConnFailure(params->hostName, params->port, + "https timeout expired"); xerr("https timeout expired"); goto cleanup; } else { if (FD_ISSET(params->sv[1], &readfds)) { swt = 0; srd = read(params->sv[1], sbuf, 32768); if (srd == -1) { if (errno != 104) // udcCache often closes causing "Connection reset by peer" xerrno("error reading https socket"); goto cleanup; @@ -332,30 +335,37 @@ } } } cleanup: BIO_free_all(sbio); close(params->sv[1]); /* we are done with it */ return NULL; } int netConnectHttps(char *hostName, int port) /* Return socket for https connection with server or -1 if error. */ { +char *errorString = NULL; +if (checkConnFailure(hostName, port, &errorString)) + { + warn(errorString); + return -1; + } + fflush(stdin); fflush(stdout); fflush(stderr); struct netConnectHttpsParams *params; AllocVar(params); params->hostName = cloneString(hostName); params->port = port; socketpair(AF_UNIX, SOCK_STREAM, 0, params->sv); int rc; rc = pthread_create(¶ms->thread, NULL, netConnectHttpsThread, (void *)params); if (rc)