Skip to content

Commit

Permalink
moved the session ID cache state variables into the UrlState struct w…
Browse files Browse the repository at this point in the history
…ithin

the SessionHandle. It was previously wrongly put in UserDefined
  • Loading branch information
bagder committed Sep 6, 2001
1 parent 86da31e commit c3b448d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
32 changes: 16 additions & 16 deletions lib/ssluse.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ CURLcode Curl_SSL_InitSessions(struct SessionHandle *data, long amount)
{
struct curl_ssl_session *session;

if(data->set.ssl.session)
if(data->state.session)
/* this is just a precaution to prevent multiple inits */
return CURLE_OK;

Expand All @@ -349,8 +349,8 @@ CURLcode Curl_SSL_InitSessions(struct SessionHandle *data, long amount)

/* store the info in the SSL section */
data->set.ssl.numsessions = amount;
data->set.ssl.session = session;
data->set.ssl.sessionage = 1; /* this is brand new */
data->state.session = session;
data->state.sessionage = 1; /* this is brand new */

return CURLE_OK;
}
Expand All @@ -367,15 +367,15 @@ static int Get_SSL_Session(struct connectdata *conn,
long i;

for(i=0; i< data->set.ssl.numsessions; i++) {
check = &data->set.ssl.session[i];
check = &data->state.session[i];
if(!check->sessionid)
/* not session ID means blank entry */
continue;
if(strequal(conn->name, check->name) &&
(conn->remote_port == check->remote_port) ) {
/* yes, we have a session ID! */
data->set.ssl.sessionage++; /* increase general age */
check->age = data->set.ssl.sessionage; /* set this as used in this age */
data->state.sessionage++; /* increase general age */
check->age = data->state.sessionage; /* set this as used in this age */
*ssl_sessionid = check->sessionid;
return FALSE;
}
Expand Down Expand Up @@ -413,13 +413,13 @@ int Curl_SSL_Close_All(struct SessionHandle *data)
{
int i;

if(data->set.ssl.session) {
if(data->state.session) {
for(i=0; i< data->set.ssl.numsessions; i++)
/* the single-killer function handles empty table slots */
Kill_Single_Session(&data->set.ssl.session[i]);
Kill_Single_Session(&data->state.session[i]);

/* free the cache data */
free(data->set.ssl.session);
free(data->state.session);
}
return 0;
}
Expand All @@ -433,7 +433,7 @@ static int Store_SSL_Session(struct connectdata *conn)
struct curl_ssl_session *store;
int i;
struct SessionHandle *data=conn->data; /* the mother of all structs */
int oldest_age=data->set.ssl.session[0].age; /* zero if unused */
int oldest_age=data->state.session[0].age; /* zero if unused */

/* ask OpenSSL, say please */
ssl_sessionid = SSL_get1_session(conn->ssl.handle);
Expand All @@ -446,21 +446,21 @@ static int Store_SSL_Session(struct connectdata *conn)
the oldest if necessary) */

/* find an empty slot for us, or find the oldest */
for(i=0; (i<data->set.ssl.numsessions) && data->set.ssl.session[i].sessionid; i++) {
if(data->set.ssl.session[i].age < oldest_age) {
oldest_age = data->set.ssl.session[i].age;
store = &data->set.ssl.session[i];
for(i=0; (i<data->set.ssl.numsessions) && 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)
/* cache is full, we must "kill" the oldest entry! */
Kill_Single_Session(store);
else
store = &data->set.ssl.session[i]; /* use this slot */
store = &data->state.session[i]; /* use this slot */

/* now init the session struct wisely */
store->sessionid = ssl_sessionid;
store->age = data->set.ssl.sessionage; /* set current age */
store->age = data->state.sessionage; /* set current age */
store->name = strdup(conn->name); /* clone host name */
store->remote_port = conn->remote_port; /* port number */

Expand Down
5 changes: 3 additions & 2 deletions lib/urldata.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ struct ssl_config_data {
char *random_file; /* path to file containing "random" data */
char *egdsocket; /* path to file containing the EGD daemon socket */

struct curl_ssl_session *session; /* array of 'numsessions' size */
long numsessions; /* SSL session id cache size */
long sessionage; /* number of the most recent session */
};

/****************************************************************************
Expand Down Expand Up @@ -437,6 +435,9 @@ struct UrlState {
following not keep sending user+password... This is
strdup() data.
*/

struct curl_ssl_session *session; /* array of 'numsessions' size */
long sessionage; /* number of the most recent session */
};


Expand Down

0 comments on commit c3b448d

Please sign in to comment.