* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
case CURL_LOCK_DATA_SSL_SESSION:
#ifdef USE_SSL
if(!share->sslsession) {
- share->nsslsession = 8;
- share->sslsession = calloc(share->nsslsession,
+ share->max_ssl_sessions = 8;
+ share->sslsession = calloc(share->max_ssl_sessions,
sizeof(struct curl_ssl_session));
share->sessionage = 0;
if(!share->sslsession)
case CURL_LOCK_DATA_SSL_SESSION:
#ifdef USE_SSL
- if(share->sslsession) {
- free(share->sslsession);
- share->sslsession = NULL;
- share->nsslsession = 0;
- }
+ Curl_safefree(share->sslsession);
break;
#else
return CURLSHE_NOT_BUILT_IN;
#ifdef USE_SSL
if(share->sslsession) {
- unsigned int i;
- for(i = 0; i < share->nsslsession; ++i)
+ size_t i;
+ for(i = 0; i < share->max_ssl_sessions; i++)
Curl_ssl_kill_session(&(share->sslsession[i]));
free(share->sslsession);
}
-#ifndef __CURL_SHARE_H
-#define __CURL_SHARE_H
-
+#ifndef HEADER_CURL_SHARE_H
+#define HEADER_CURL_SHARE_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
#endif
struct curl_ssl_session *sslsession;
- unsigned int nsslsession;
+ size_t max_ssl_sessions;
long sessionage;
};
curl_lock_access);
CURLSHcode Curl_share_unlock (struct SessionHandle *, curl_lock_data);
-#endif /* __CURL_SHARE_H */
+#endif /* HEADER_CURL_SHARE_H */
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
{
struct curl_ssl_session *check;
struct SessionHandle *data = conn->data;
- long i;
+ size_t i;
long *general_age;
bool no_match = TRUE;
else
general_age = &data->state.sessionage;
- for(i=0; i< data->set.ssl.numsessions; i++) {
+ for(i = 0; i < data->set.ssl.max_ssl_sessions; i++) {
check = &data->state.session[i];
if(!check->sessionid)
/* not session ID means blank entry */
/*
* Kill a single session ID entry in the cache.
*/
-int Curl_ssl_kill_session(struct curl_ssl_session *session)
+void Curl_ssl_kill_session(struct curl_ssl_session *session)
{
if(session->sessionid) {
/* defensive check */
/* free the ID the SSL-layer specific way */
curlssl_session_free(session->sessionid);
- session->sessionid=NULL;
+ session->sessionid = NULL;
session->age = 0; /* fresh */
Curl_free_ssl_config(&session->ssl_config);
Curl_safefree(session->name);
- session->name = NULL; /* no name */
-
- return 0; /* ok */
}
- else
- return 1;
}
/*
*/
void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid)
{
- int i;
+ size_t i;
struct SessionHandle *data=conn->data;
if(SSLSESSION_SHARED(data))
- Curl_share_lock(data, CURL_LOCK_DATA_SSL_SESSION,
- CURL_LOCK_ACCESS_SINGLE);
+ Curl_share_lock(data, CURL_LOCK_DATA_SSL_SESSION, CURL_LOCK_ACCESS_SINGLE);
- for(i=0; i< data->set.ssl.numsessions; i++) {
+ for(i = 0; i < data->set.ssl.max_ssl_sessions; i++) {
struct curl_ssl_session *check = &data->state.session[i];
if(check->sessionid == ssl_sessionid) {
void *ssl_sessionid,
size_t idsize)
{
- long i;
+ size_t i;
struct SessionHandle *data=conn->data; /* the mother of all structs */
struct curl_ssl_session *store = &data->state.session[0];
long oldest_age=data->state.session[0].age; /* zero if unused */
}
/* find an empty slot for us, or find the oldest */
- for(i=1; (i<data->set.ssl.numsessions) &&
+ for(i = 1; (i < data->set.ssl.max_ssl_sessions) &&
data->state.session[i].sessionid; i++) {
if(data->state.session[i].age < oldest_age) {
oldest_age = data->state.session[i].age;
store = &data->state.session[i];
}
}
- if(i == data->set.ssl.numsessions)
+ if(i == data->set.ssl.max_ssl_sessions)
/* cache is full, we must "kill" the oldest entry! */
Curl_ssl_kill_session(store);
else
void Curl_ssl_close_all(struct SessionHandle *data)
{
- long i;
+ size_t i;
/* kill the session ID cache if not shared */
if(data->state.session && !SSLSESSION_SHARED(data)) {
- for(i=0; i< data->set.ssl.numsessions; i++)
+ for(i = 0; i < data->set.ssl.max_ssl_sessions; i++)
/* the single-killer function handles empty table slots */
Curl_ssl_kill_session(&data->state.session[i]);
/* free the cache data */
- free(data->state.session);
- data->state.session = NULL;
+ Curl_safefree(data->state.session);
}
curlssl_close_all(data);
* This sets up a session ID cache to the specified size. Make sure this code
* is agnostic to what underlying SSL technology we use.
*/
-CURLcode Curl_ssl_initsessions(struct SessionHandle *data, long amount)
+CURLcode Curl_ssl_initsessions(struct SessionHandle *data, size_t amount)
{
struct curl_ssl_session *session;
return CURLE_OUT_OF_MEMORY;
/* store the info in the SSL section */
- data->set.ssl.numsessions = amount;
+ data->set.ssl.max_ssl_sessions = amount;
data->state.session = session;
data->state.sessionage = 1; /* this is brand new */
return CURLE_OK;
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
struct curl_slist *Curl_ssl_engines_list(struct SessionHandle *data);
/* init the SSL session ID cache */
-CURLcode Curl_ssl_initsessions(struct SessionHandle *, long);
+CURLcode Curl_ssl_initsessions(struct SessionHandle *, size_t);
size_t Curl_ssl_version(char *buffer, size_t size);
bool Curl_ssl_data_pending(const struct connectdata *conn,
int connindex);
void *ssl_sessionid,
size_t idsize);
/* Kill a single session ID entry in the cache */
-int Curl_ssl_kill_session(struct curl_ssl_session *session);
+void Curl_ssl_kill_session(struct curl_ssl_session *session);
/* delete a session from the cache */
void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid);
#define Curl_ssl_check_cxn(x) 0
#define Curl_ssl_free_certinfo(x) Curl_nop_stmt
#define Curl_ssl_connect_nonblocking(x,y,z) CURLE_NOT_BUILT_IN
-#define Curl_ssl_kill_session(x) 0
+#define Curl_ssl_kill_session(x) Curl_nop_stmt
#endif
#endif /* HEADER_CURL_SSLGEN_H */
}
/* Init the SSL session ID cache here. We do it here since we want to do it
- after the *_setopt() calls (that could change the size of the cache) but
+ after the *_setopt() calls (that could specify the size of the cache) but
before any transfer takes place. */
- res = Curl_ssl_initsessions(data, data->set.ssl.numsessions);
+ res = Curl_ssl_initsessions(data, data->set.ssl.max_ssl_sessions);
if(res)
return res;
set->dns_cache_timeout = 60; /* Timeout every 60 seconds by default */
/* Set the default size of the SSL session ID cache */
- set->ssl.numsessions = 5;
+ set->ssl.max_ssl_sessions = 5;
set->proxyport = CURL_DEFAULT_PROXY_PORT; /* from url.h */
set->proxytype = CURLPROXY_HTTP; /* defaults to HTTP proxy */
data->cookies = NULL;
#endif
- if(data->share->sslsession == data->state.session) {
+ if(data->share->sslsession == data->state.session)
data->state.session = NULL;
- data->set.ssl.numsessions = 0;
- }
data->share->dirty--;
}
#endif /* CURL_DISABLE_HTTP */
if(data->share->sslsession) {
- data->set.ssl.numsessions = data->share->nsslsession;
+ data->set.ssl.max_ssl_sessions = data->share->max_ssl_sessions;
data->state.session = data->share->sslsession;
}
Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
char *random_file; /* path to file containing "random" data */
char *egdsocket; /* path to file containing the EGD daemon socket */
char *cipher_list; /* list of ciphers to use */
- long numsessions; /* SSL session id cache size */
+ size_t max_ssl_sessions; /* SSL session id cache size */
curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
void *fsslctxp; /* parameter for call back */
bool sessionid; /* cache session IDs or not */
following not keep sending user+password... This is
strdup() data.
*/
- struct curl_ssl_session *session; /* array of 'numsessions' size */
+ struct curl_ssl_session *session; /* array of 'max_ssl_sessions' size */
long sessionage; /* number of the most recent session */
char *tempwrite; /* allocated buffer to keep data in when a write
callback returns to make the connection paused */