aboutsummaryrefslogtreecommitdiffstats
path: root/src/gnutls_cache.c
diff options
context:
space:
mode:
authorGravatar Nikos Mavrogiannopoulos 2007-11-28 18:29:21 +0000
committerGravatar Nokis Mavrogiannopoulos 2007-11-28 18:29:21 +0000
commit7bebb42365c3bf0bee9e4618dc45bd8ca5d164a1 (patch)
treea5d6d38a76da9f3a36205294c5bfb8e0b3f0d96d /src/gnutls_cache.c
parent8e33f2d4c149fe8b6d2f1f3bdb06c52da53952f1 (diff)
upgraded to 0.4.0
Diffstat (limited to 'src/gnutls_cache.c')
-rw-r--r--src/gnutls_cache.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/gnutls_cache.c b/src/gnutls_cache.c
index 4c094fa..86b843e 100644
--- a/src/gnutls_cache.c
+++ b/src/gnutls_cache.c
@@ -38,6 +38,7 @@
38 (sizeof(MC_TAG)) 38 (sizeof(MC_TAG))
39#define STR_SESSION_LEN (GNUTLS_SESSION_ID_STRING_LEN + MC_TAG_LEN) 39#define STR_SESSION_LEN (GNUTLS_SESSION_ID_STRING_LEN + MC_TAG_LEN)
40 40
41#if 0
41static char *gnutls_session_id2sz(unsigned char *id, int idlen, 42static char *gnutls_session_id2sz(unsigned char *id, int idlen,
42 char *str, int strsize) 43 char *str, int strsize)
43{ 44{
@@ -52,6 +53,22 @@ static char *gnutls_session_id2sz(unsigned char *id, int idlen,
52 *cp = '\0'; 53 *cp = '\0';
53 return str; 54 return str;
54} 55}
56#endif
57
58#define CTIME "%b %d %k:%M:%S %Y %Z"
59char *mgs_time2sz(time_t in_time, char *str, int strsize)
60{
61 apr_time_exp_t vtm;
62 apr_size_t ret_size;
63 apr_time_t t;
64
65
66 apr_time_ansi_put (&t, in_time);
67 apr_time_exp_gmt (&vtm, t);
68 apr_strftime(str, &ret_size, strsize-1, CTIME, &vtm);
69
70 return str;
71}
55 72
56char *mgs_session_id2sz(unsigned char *id, int idlen, 73char *mgs_session_id2sz(unsigned char *id, int idlen,
57 char *str, int strsize) 74 char *str, int strsize)
@@ -349,11 +366,9 @@ static gnutls_datum_t dbm_cache_fetch(void* baton, gnutls_datum_t key)
349 mgs_handle_t *ctxt = baton; 366 mgs_handle_t *ctxt = baton;
350 apr_status_t rv; 367 apr_status_t rv;
351 368
352 dbmkey.dptr = key.data; 369 dbmkey.dptr = (void*)key.data;
353 dbmkey.dsize = key.size; 370 dbmkey.dsize = key.size;
354 371
355 dbm_cache_expire(ctxt);
356
357 rv = apr_dbm_open(&dbm, ctxt->sc->cache_config, 372 rv = apr_dbm_open(&dbm, ctxt->sc->cache_config,
358 APR_DBM_RWCREATE, SSL_DBM_FILE_MODE, ctxt->c->pool); 373 APR_DBM_RWCREATE, SSL_DBM_FILE_MODE, ctxt->c->pool);
359 if (rv != APR_SUCCESS) { 374 if (rv != APR_SUCCESS) {
@@ -412,6 +427,8 @@ static int dbm_cache_store(void* baton, gnutls_datum_t key,
412 memcpy((char *)dbmval.dptr+sizeof(apr_time_t), 427 memcpy((char *)dbmval.dptr+sizeof(apr_time_t),
413 data.data, data.size); 428 data.data, data.size);
414 429
430 /* we expire dbm only on every store
431 */
415 dbm_cache_expire(ctxt); 432 dbm_cache_expire(ctxt);
416 433
417 rv = apr_dbm_open(&dbm, ctxt->sc->cache_config, 434 rv = apr_dbm_open(&dbm, ctxt->sc->cache_config,
@@ -454,8 +471,6 @@ static int dbm_cache_delete(void* baton, gnutls_datum_t key)
454 dbmkey.dptr = (char *)key.data; 471 dbmkey.dptr = (char *)key.data;
455 dbmkey.dsize = key.size; 472 dbmkey.dsize = key.size;
456 473
457 dbm_cache_expire(ctxt);
458
459 rv = apr_dbm_open(&dbm, ctxt->sc->cache_config, 474 rv = apr_dbm_open(&dbm, ctxt->sc->cache_config,
460 APR_DBM_RWCREATE, SSL_DBM_FILE_MODE, ctxt->c->pool); 475 APR_DBM_RWCREATE, SSL_DBM_FILE_MODE, ctxt->c->pool);
461 if (rv != APR_SUCCESS) { 476 if (rv != APR_SUCCESS) {