}
/* subtract elapsed time */
- timeout_ms -= Curl_tvdiff(*nowp, data->progress.t_startsingle);
+ if(duringconnect)
+ /* since this most recent connect started */
+ timeout_ms -= Curl_tvdiff(*nowp, data->progress.t_startsingle);
+ else
+ /* since the entire operation started */
+ timeout_ms -= Curl_tvdiff(*nowp, data->progress.t_startop);
if(!timeout_ms)
/* avoid returning 0 as that means no timeout! */
return -1;
conn->tempsock[tempindex] = CURL_SOCKET_BAD;
if(sockindex == FIRSTSOCKET) {
- Curl_addrinfo *ai;
- int family;
+ Curl_addrinfo *ai = NULL;
+ int family = AF_UNSPEC;
if(conn->tempaddr[tempindex]) {
/* find next address in the same protocol family */
family = conn->tempaddr[tempindex]->ai_family;
ai = conn->tempaddr[tempindex]->ai_next;
}
- else {
+ else if(conn->tempaddr[0]) {
/* happy eyeballs - try the other protocol family */
int firstfamily = conn->tempaddr[0]->ai_family;
#ifdef ENABLE_IPV6
if(ai) {
rc = singleipconnect(conn, ai, &conn->tempsock[tempindex]);
- conn->tempaddr[tempindex] = ai;
if(rc == CURLE_COULDNT_CONNECT) {
ai = ai->ai_next;
continue;
}
+ conn->tempaddr[tempindex] = ai;
}
break;
}
char ipaddress[MAX_IPADR_LEN];
data->state.os_errno = error;
SET_SOCKERRNO(error);
- Curl_printable_address(conn->tempaddr[i], ipaddress, MAX_IPADR_LEN);
- infof(data, "connect to %s port %ld failed: %s\n",
- ipaddress, conn->port, Curl_strerror(conn, error));
+ if(conn->tempaddr[i]) {
+ Curl_printable_address(conn->tempaddr[i], ipaddress, MAX_IPADR_LEN);
+ infof(data, "connect to %s port %ld failed: %s\n",
+ ipaddress, conn->port, Curl_strerror(conn, error));
- conn->timeoutms_per_addr = conn->tempaddr[i]->ai_next == NULL ?
- allow : allow / 2;
+ conn->timeoutms_per_addr = conn->tempaddr[i]->ai_next == NULL ?
+ allow : allow / 2;
- code = trynextip(conn, sockindex, i);
+ code = trynextip(conn, sockindex, i);
+ }
}
}
static int detectOsState = DETECT_OS_NONE;
if(detectOsState == DETECT_OS_NONE) {
-#if !defined(VerifyVersionInfo)
+#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_WIN2K) || \
+ (_WIN32_WINNT < _WIN32_WINNT_WIN2K)
OSVERSIONINFO osver;
memset(&osver, 0, sizeof(osver));
memset(&osver, 0, sizeof(osver));
osver.dwOSVersionInfoSize = sizeof(osver);
osver.dwMajorVersion = majorVersion;
- majorVersionMask = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
+ majorVersionMask = VerSetConditionMask(0, VER_MAJORVERSION,
+ VER_GREATER_EQUAL);
if(VerifyVersionInfo(&osver, VER_MAJORVERSION, majorVersionMask))
detectOsState = DETECT_OS_VISTA_OR_LATER;
return CURLE_OK;
}
+
+#ifdef CURLDEBUG
+/*
+ * Curl_conncontrol() is used to set the conn->bits.close bit on or off. It
+ * MUST be called with the connclose() or connclose() macros with a stated
+ * reason. The reason is only shown in debug builds but helps to figure out
+ * decision paths when connections are or aren't re-used as expected.
+ */
+void Curl_conncontrol(struct connectdata *conn, bool closeit,
+ const char *reason)
+{
+ infof(conn->data, "Marked for [%s]: %s\n", closeit?"closure":"keep alive",
+ reason);
+ conn->bits.close = closeit; /* the only place in the source code that should
+ assign this bit */
+}
+#endif