Commit a1f32ffe authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

ip_version: moved to connection struct

The IP version choice was previously only in the UserDefined struct
within the SessionHandle, but since we sometimes alter that option
during a request we need to have it on a per-connection basis.

I also moved more "init conn" code into the allocate_conn() function
which is designed for that purpose more or less.
parent fec5f03e
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -310,20 +310,20 @@ static CURLcode bindlocal(struct connectdata *conn,
       * of the connection. The resolve functions should really be changed
       * to take a type parameter instead.
       */
      long ipver = data->set.ip_version;
      long ipver = conn->ip_version;
      int rc;

      if (af == AF_INET)
        data->set.ip_version = CURL_IPRESOLVE_V4;
        conn->ip_version = CURL_IPRESOLVE_V4;
#ifdef ENABLE_IPV6
      else if (af == AF_INET6)
        data->set.ip_version = CURL_IPRESOLVE_V6;
        conn->ip_version = CURL_IPRESOLVE_V6;
#endif

      rc = Curl_resolv(conn, dev, 0, &h);
      if(rc == CURLRESOLV_PENDING)
        (void)Curl_wait_for_resolv(conn, &h);
      data->set.ip_version = ipver;
      conn->ip_version = ipver;

      if(h) {
        /* convert the resolved address, sizeof myhost >= INET_ADDRSTRLEN */
+1 −1
Original line number Diff line number Diff line
@@ -378,7 +378,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
    return Curl_ip2addr(AF_INET6, &in6, hostname, port);
  }

  switch(data->set.ip_version) {
  switch(conn->ip_version) {
  default:
#if ARES_VERSION >= 0x010601
    family = PF_UNSPEC; /* supported by c-ares since 1.6.1, so for older
+1 −1
Original line number Diff line number Diff line
@@ -444,7 +444,7 @@ int Curl_resolv(struct connectdata *conn,

    /* Check what IP specifics the app has requested and if we can provide it.
     * If not, bail out. */
    if(!Curl_ipvalid(data))
    if(!Curl_ipvalid(conn))
      return CURLRESOLV_ERROR;

    /* If Curl_getaddrinfo() returns NULL, 'respwait' might be set to a
+1 −1
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ int Curl_resolv_timeout(struct connectdata *conn, const char *hostname,
 * Curl_ipvalid() checks what CURL_IPRESOLVE_* requirements that might've
 * been set and returns TRUE if they are OK.
 */
bool Curl_ipvalid(struct SessionHandle *data);
bool Curl_ipvalid(struct connectdata *conn);

/*
 * Curl_getaddrinfo() is the generic low-level name resolve API within this
+2 −2
Original line number Diff line number Diff line
@@ -77,9 +77,9 @@
 * Curl_ipvalid() checks what CURL_IPRESOLVE_* requirements that might've
 * been set and returns TRUE if they are OK.
 */
bool Curl_ipvalid(struct SessionHandle *data)
bool Curl_ipvalid(struct connectdata *conn)
{
  if(data->set.ip_version == CURL_IPRESOLVE_V6)
  if(conn->ip_version == CURL_IPRESOLVE_V6)
    /* an ipv6 address was requested and we can't get/use one */
    return FALSE;

Loading