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

keep 'socktype' in the connectdata struct and make sure we use that for all

protocol sockets even if the resolved address may say otherwise
parent d0a4104c
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -631,8 +631,9 @@ singleipconnect(struct connectdata *conn,
  int error;
  bool conected;
  struct SessionHandle *data = conn->data;
  curl_socket_t sockfd = socket(ai->ai_family, ai->ai_socktype,
                                ai->ai_protocol);
  curl_socket_t sockfd;

  sockfd = socket(ai->ai_family, conn->socktype, ai->ai_protocol);
  if (sockfd == CURL_SOCKET_BAD)
    return CURL_SOCKET_BAD;

@@ -661,11 +662,10 @@ singleipconnect(struct connectdata *conn,
  Curl_nonblock(sockfd, TRUE);

  /* Connect TCP sockets, bind UDP */
  if(ai->ai_socktype==SOCK_STREAM) {
  if(conn->socktype == SOCK_STREAM)
    rc = connect(sockfd, ai->ai_addr, (socklen_t)ai->ai_addrlen);
  } else {
  else
    rc = 0;
  }

  if(-1 == rc) {
    error = Curl_ourerrno();
+1 −1
Original line number Diff line number Diff line
@@ -858,7 +858,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
     * Workaround for AIX5 getaddrinfo() problem (it doesn't set ai_socktype):
     */
    if (ai->ai_socktype == 0)
      ai->ai_socktype = SOCK_STREAM;
      ai->ai_socktype = conn->socktype;

    portsock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
    if (portsock == CURL_SOCKET_BAD) {
+4 −4
Original line number Diff line number Diff line
@@ -423,9 +423,9 @@ Curl_addrinfo *Curl_he2ai(struct hostent *he, int port)
      prevai->ai_next = ai;

    ai->ai_family = AF_INET;              /* we only support this */
    if(port == PORT_TFTP)
      ai->ai_socktype = SOCK_DGRAM;
    else

    /* we return all names as STREAM, so when using this address for TFTP
       the type must be ignored and conn->socktype be used instead! */
    ai->ai_socktype = SOCK_STREAM;

    ai->ai_addrlen = sizeof(struct sockaddr_in);
+1 −4
Original line number Diff line number Diff line
@@ -252,10 +252,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = pf;

  if(conn->protocol & PROT_TFTP)
    hints.ai_socktype = SOCK_DGRAM;
  else
    hints.ai_socktype = SOCK_STREAM;
  hints.ai_socktype = conn->socktype;

  hints.ai_flags = ai_flags;
  snprintf(sbuf, sizeof(sbuf), "%d", port);
+5 −5
Original line number Diff line number Diff line
@@ -559,7 +559,10 @@ static bool init_resolve_thread (struct connectdata *conn,
   */
  thread_and_event[0] = td->thread_hnd;
  thread_and_event[1] = td->event_thread_started;
  if (WaitForMultipleObjects(sizeof(thread_and_event) / sizeof(thread_and_event[0]), thread_and_event, FALSE, INFINITE) == WAIT_FAILED) {
  if (WaitForMultipleObjects(sizeof(thread_and_event) /
                             sizeof(thread_and_event[0]),
                             thread_and_event, FALSE,
                             INFINITE) == WAIT_FAILED) {
    /* The resolver thread has been created,
     * most probably it works now - ignoring this "minor" error
     */
@@ -804,10 +807,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,

  memset(&hints, 0, sizeof(hints));
  hints.ai_family = pf;
  if(conn->protocol & PROT_TFTP)
    hints.ai_socktype = SOCK_DGRAM;
  else
    hints.ai_socktype = SOCK_STREAM;
  hints.ai_socktype = conn->socktype;
  hints.ai_flags = AI_CANONNAME;
  itoa(port, sbuf, 10);

Loading