cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Q: about SSL_connect and sockfd in lib/ssluse.c

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Thu, 5 May 2005 13:33:49 +0200 (CEST)

On Thu, 5 May 2005, Alexander Lazic wrote:

> How about to set the socket to blocking an then call SSL_connect?

Sorry, but that would be to move in the totally wrong direction. The general
plan is to completely get rid of all blocking functions, and that requires
non-blocking sockets.

> Then it is possible to make the following:
>
> <pseudocode>
> Curl_nonblock(sockfd, FALSE);
> start=time(NULL);
> SSL_connect();
> ssl_handshake_duration = time(NULL)-start;
> Curl_nonblock(sockfd, TRUE);
> </pseudocode>

This exact sequence is still possible using non-blocking sockets. The
SSL_connect() is completed once the while() loop is finished.

> and you don't need the while() loop anymore ;-))

It would have the _exact_ same problem, while admittingly using slightly less
code.

The Correct Fix (tm) implies making sure that the function returns immediately
intead of looping and then having another function that checks for
completeness, so that multi.c can use that and have a separate state for SSL
connecting. That would then allow apps to use the multi interface without
"hanging" during the SSL connect phase.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2005-05-05