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
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
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)
{
bool result = FALSE;
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))
{
result = TRUE;
}
return result;
}
static bool
init_ssl_config(struct SessionHandle* data, struct connectdata* conn)
{
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;
}
if(data->set.ssl.CApath) {
conn->ssl_config.CApath = strdup(data->set.ssl.CApath);
if(!conn->ssl_config.CApath) return FALSE;
}
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;
}
if(data->set.ssl.egdsocket) {
conn->ssl_config.egdsocket = strdup(data->set.ssl.egdsocket);
if(!conn->ssl_config.egdsocket) return FALSE;
}
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;
}
return TRUE;
}
static void free_ssl_config(struct ssl_config_data* sslc)
{
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);
}