Commit 83367f67 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

Xavier Bouchoux made the SSL connection non-blocking for the multi interface

(when using OpenSSL).
parent 15f2647d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -7,6 +7,9 @@
                                  Changelog

Daniel (21 March 2006)
- Xavier Bouchoux made the SSL connection non-blocking for the multi interface
  (when using OpenSSL).

- Tor Arntsen fixed the AIX Toolbox RPM spec

Daniel (20 March 2006)
+2 −2
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ Curl and libcurl 7.15.4

This release includes the following changes:

 o 
 o less blocking for the multi interface during SSL connect negotiation 

This release includes the following bugfixes:

@@ -27,6 +27,6 @@ Other curl-related news since the previous public release:
This release would not have looked like this without help, code, reports and
advice from friends like these:

 Dan Fandrich, Ilja van Sprundel, David McCreedy, Tor Arntsen
 Dan Fandrich, Ilja van Sprundel, David McCreedy, Tor Arntsen, Xavier Bouchoux

        Thanks! (and sorry if I forgot to mention someone)
+58 −8
Original line number Diff line number Diff line
@@ -1371,13 +1371,6 @@ CURLcode Curl_http_connect(struct connectdata *conn, bool *done)
      return result;
  }

  if(conn->protocol & PROT_HTTPS) {
    /* perform SSL initialization for this socket */
    result = Curl_ssl_connect(conn, FIRSTSOCKET);
    if(result)
      return result;
  }

  if(!data->state.this_is_a_follow) {
    /* this is not a followed location, get the original host name */
    if (data->state.first_host)
@@ -1387,11 +1380,68 @@ CURLcode Curl_http_connect(struct connectdata *conn, bool *done)
    data->state.first_host = strdup(conn->host.name);
  }

  if(conn->protocol & PROT_HTTPS) {
    /* perform SSL initialization */
    if(data->state.used_interface == Curl_if_multi) {
      result = Curl_https_connecting(conn, done);
      if(result)
        return result;
    }
    else {
      /* BLOCKING */
      result = Curl_ssl_connect(conn, FIRSTSOCKET);
      if(result)
        return result;
      *done = TRUE;
    }
  }
  else {
    *done = TRUE;
  }

  return CURLE_OK;
}

CURLcode Curl_https_connecting(struct connectdata *conn, bool *done)
{
  CURLcode result;
  curlassert(conn->protocol & PROT_HTTPS);

  /* perform SSL initialization for this socket */
  result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, done);
  if(result)
    return result;

  return CURLE_OK;
}

#ifdef USE_SSLEAY
CURLcode Curl_https_proto_fdset(struct connectdata *conn,
                                fd_set *read_fd_set,
                                fd_set *write_fd_set,
                                int *max_fdp)
{
  if (conn->protocol & PROT_HTTPS) {
    struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
    curl_socket_t sockfd = conn->sock[FIRSTSOCKET];

    if (connssl->connecting_state == ssl_connect_2_writing) {
      /* write mode */
      FD_SET(sockfd, write_fd_set);
      if((int)sockfd > *max_fdp)
        *max_fdp = (int)sockfd;
    }
    else if (connssl->connecting_state == ssl_connect_2_reading) {
      /* read mode */
      FD_SET(sockfd, read_fd_set);
      if((int)sockfd > *max_fdp)
        *max_fdp = (int)sockfd;
    }
  }
  return CURLE_OK;
}
#endif

/*
 * Curl_http_done() gets called from Curl_done() after a single HTTP request
 * has been performed.
+5 −0
Original line number Diff line number Diff line
@@ -37,6 +37,11 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
CURLcode Curl_http(struct connectdata *conn, bool *done);
CURLcode Curl_http_done(struct connectdata *, CURLcode);
CURLcode Curl_http_connect(struct connectdata *conn, bool *done);
CURLcode Curl_https_connecting(struct connectdata *conn, bool *done);
CURLcode Curl_https_proto_fdset(struct connectdata *conn,
                                fd_set *read_fd_set,
                                fd_set *write_fd_set,
                                int *max_fdp);

/* The following functions are defined in http_chunks.c */
void Curl_httpchunk_init(struct connectdata *conn);
+18 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -215,6 +215,23 @@ Curl_ssl_connect(struct connectdata *conn, int sockindex)
#endif /* USE_SSL */
}

CURLcode
Curl_ssl_connect_nonblocking(struct connectdata *conn, int sockindex,
                             bool *done)
{
#if defined(USE_SSL) && defined(USE_SSLEAY)
  /* mark this is being ssl enabled from here on. */
  conn->ssl[sockindex].use = TRUE;
  return Curl_ossl_connect_nonblocking(conn, sockindex, done);

#else
  /* not implemented!
     fallback to BLOCKING call. */
  *done = TRUE;
  return Curl_ssl_connect(conn, sockindex);
#endif
}

#ifdef USE_SSL

/*
Loading