Newer
Older
CURLcode result=CURLE_OK;
struct connectdata *conn = *connp;
struct SessionHandle *data=conn->data;
conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to use */
/* generic protocol-specific function pointer set in curl_connect() */
result = conn->curl_do(conn);
/* This was formerly done in transfer.c, but we better do it here */
if((CURLE_SEND_ERROR == result) && conn->bits.reuse) {
/* This was a re-use of a connection and we got a write error in the
* DO-phase. Then we DISCONNECT this connection and have another attempt
* to CONNECT and then DO again! The retry cannot possibly find another
* connection to re-use, since we only keep one possible connection for
* each. */
infof(data, "Re-used connection seems dead, get a new one\n");
conn->bits.close = TRUE; /* enforce close of this connetion */
result = Curl_done(conn); /* we are so done with this */
if(CURLE_OK == result) {
/* Now, redo the connect and get a new connection */
result = Curl_connect(data, connp);
if(CURLE_OK == result)
/* ... finally back to actually retry the DO phase */
result = conn->curl_do(*connp);
}
}
}
CURLcode Curl_do_more(struct connectdata *conn)
{
CURLcode result=CURLE_OK;
if(conn->curl_do_more)
result = conn->curl_do_more(conn);
return result;
}
Daniel Stenberg
committed
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
static bool safe_strequal(char* str1, char* str2)
{
if(str1 && str2)
/* both pointers point to something then compare them */
return strequal(str1, str2);
else
/* if both pointers are NULL then treat them as equal */
return (!str1 && !str2);
}
static bool
ssl_config_matches(struct ssl_config_data* data,
struct ssl_config_data* needle)
{
if((data->version == needle->version) &&
(data->verifypeer == needle->verifypeer) &&
(data->verifyhost == needle->verifyhost) &&
safe_strequal(data->CApath, needle->CApath) &&
safe_strequal(data->CAfile, needle->CAfile) &&
safe_strequal(data->random_file, needle->random_file) &&
safe_strequal(data->egdsocket, needle->egdsocket) &&
safe_strequal(data->cipher_list, needle->cipher_list))
Daniel Stenberg
committed
Daniel Stenberg
committed
}
static bool
init_ssl_config(struct SessionHandle* data, struct connectdata* conn)
Daniel Stenberg
committed
{
conn->ssl_config.verifyhost = data->set.ssl.verifyhost;
conn->ssl_config.verifypeer = data->set.ssl.verifypeer;
conn->ssl_config.version = data->set.ssl.version;
if(data->set.ssl.CAfile) {
conn->ssl_config.CAfile = strdup(data->set.ssl.CAfile);
if(!conn->ssl_config.CAfile)
return FALSE;
Daniel Stenberg
committed
}
if(data->set.ssl.CApath) {
conn->ssl_config.CApath = strdup(data->set.ssl.CApath);
if(!conn->ssl_config.CApath)
return FALSE;
Daniel Stenberg
committed
}
if(data->set.ssl.cipher_list) {
conn->ssl_config.cipher_list = strdup(data->set.ssl.cipher_list);
if(!conn->ssl_config.cipher_list)
return FALSE;
Daniel Stenberg
committed
}
if(data->set.ssl.egdsocket) {
conn->ssl_config.egdsocket = strdup(data->set.ssl.egdsocket);
if(!conn->ssl_config.egdsocket)
return FALSE;
Daniel Stenberg
committed
}
if(data->set.ssl.random_file) {
conn->ssl_config.random_file = strdup(data->set.ssl.random_file);
if(!conn->ssl_config.random_file)
return FALSE;
Daniel Stenberg
committed
}
return TRUE;
}
static void free_ssl_config(struct ssl_config_data* sslc)
Daniel Stenberg
committed
{
if(sslc->CAfile)
free(sslc->CAfile);
if(sslc->CApath)
free(sslc->CApath);
if(sslc->cipher_list)
free(sslc->cipher_list);
if(sslc->egdsocket)
free(sslc->egdsocket);
if(sslc->random_file)
free(sslc->random_file);
}