aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikos Mavrogiannopoulos 2010-09-23 09:27:03 +0200
committerGravatar Nikos Mavrogiannopoulos 2010-09-23 09:35:27 +0200
commit771ca63efe669f8b0a3ffaeba1f3be7e3688b35f (patch)
tree4f0694c0c060aa03f0e2c9ccfae965b74a463e71 /src
parent0fce7c2dd90a0d5214be02a09bf694c7cd0289aa (diff)
The GnuTLSCache variable now can be given the specific
option "sdbm" instead of "dbm". "dbm" will use the default dbm type of libapr while sdbm will force sdbm to be used.
Diffstat (limited to 'src')
-rw-r--r--src/gnutls_cache.c28
-rw-r--r--src/gnutls_config.c10
2 files changed, 24 insertions, 14 deletions
diff --git a/src/gnutls_cache.c b/src/gnutls_cache.c
index 3ca8cb5..7bcb697 100644
--- a/src/gnutls_cache.c
+++ b/src/gnutls_cache.c
@@ -35,8 +35,6 @@
35 35
36/* it seems the default has some strange errors. Use SDBM 36/* it seems the default has some strange errors. Use SDBM
37 */ 37 */
38#define ODB "SDBM"
39
40#define MC_TAG "mod_gnutls:" 38#define MC_TAG "mod_gnutls:"
41#define MC_TAG_LEN sizeof(MC_TAG) 39#define MC_TAG_LEN sizeof(MC_TAG)
42#define STR_SESSION_LEN (GNUTLS_SESSION_ID_STRING_LEN + MC_TAG_LEN) 40#define STR_SESSION_LEN (GNUTLS_SESSION_ID_STRING_LEN + MC_TAG_LEN)
@@ -296,6 +294,14 @@ static int mc_cache_delete(void* baton, gnutls_datum_t key)
296 294
297#endif /* have_apr_memcache */ 295#endif /* have_apr_memcache */
298 296
297const char* db_type(mgs_srvconf_rec * sc)
298{
299 if (sc->cache_type == mgs_cache_sdbm)
300 return "sdbm";
301 else
302 return "default";
303}
304
299#define SSL_DBM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD ) 305#define SSL_DBM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD )
300 306
301static void dbm_cache_expire(mgs_handle_t *ctxt) 307static void dbm_cache_expire(mgs_handle_t *ctxt)
@@ -321,7 +327,7 @@ static void dbm_cache_expire(mgs_handle_t *ctxt)
321 total = 0; 327 total = 0;
322 deleted = 0; 328 deleted = 0;
323 329
324 rv = apr_dbm_open_ex(&dbm, ODB, ctxt->sc->cache_config, APR_DBM_RWCREATE, 330 rv = apr_dbm_open_ex(&dbm, db_type(ctxt->sc), ctxt->sc->cache_config, APR_DBM_RWCREATE,
325 SSL_DBM_FILE_MODE, spool); 331 SSL_DBM_FILE_MODE, spool);
326 if (rv != APR_SUCCESS) { 332 if (rv != APR_SUCCESS) {
327 ap_log_error(APLOG_MARK, APLOG_NOTICE, rv, 333 ap_log_error(APLOG_MARK, APLOG_NOTICE, rv,
@@ -374,7 +380,7 @@ static gnutls_datum_t dbm_cache_fetch(void* baton, gnutls_datum_t key)
374 if (mgs_session_id2dbm(ctxt->c, key.data, key.size, &dbmkey) < 0) 380 if (mgs_session_id2dbm(ctxt->c, key.data, key.size, &dbmkey) < 0)
375 return data; 381 return data;
376 382
377 rv = apr_dbm_open_ex(&dbm, ODB, ctxt->sc->cache_config, 383 rv = apr_dbm_open_ex(&dbm, db_type(ctxt->sc), ctxt->sc->cache_config,
378 APR_DBM_READONLY, SSL_DBM_FILE_MODE, ctxt->c->pool); 384 APR_DBM_READONLY, SSL_DBM_FILE_MODE, ctxt->c->pool);
379 if (rv != APR_SUCCESS) { 385 if (rv != APR_SUCCESS) {
380 ap_log_error(APLOG_MARK, APLOG_NOTICE, rv, 386 ap_log_error(APLOG_MARK, APLOG_NOTICE, rv,
@@ -444,7 +450,7 @@ static int dbm_cache_store(void* baton, gnutls_datum_t key,
444 memcpy((char *)dbmval.dptr+sizeof(apr_time_t), 450 memcpy((char *)dbmval.dptr+sizeof(apr_time_t),
445 data.data, data.size); 451 data.data, data.size);
446 452
447 rv = apr_dbm_open_ex(&dbm, ODB, ctxt->sc->cache_config, 453 rv = apr_dbm_open_ex(&dbm, db_type(ctxt->sc), ctxt->sc->cache_config,
448 APR_DBM_RWCREATE, SSL_DBM_FILE_MODE, ctxt->c->pool); 454 APR_DBM_RWCREATE, SSL_DBM_FILE_MODE, ctxt->c->pool);
449 if (rv != APR_SUCCESS) { 455 if (rv != APR_SUCCESS) {
450 ap_log_error(APLOG_MARK, APLOG_NOTICE, rv, 456 ap_log_error(APLOG_MARK, APLOG_NOTICE, rv,
@@ -484,7 +490,7 @@ static int dbm_cache_delete(void* baton, gnutls_datum_t key)
484 if (mgs_session_id2dbm(ctxt->c, key.data, key.size, &dbmkey) < 0) 490 if (mgs_session_id2dbm(ctxt->c, key.data, key.size, &dbmkey) < 0)
485 return -1; 491 return -1;
486 492
487 rv = apr_dbm_open_ex(&dbm, ODB, ctxt->sc->cache_config, 493 rv = apr_dbm_open_ex(&dbm, db_type(ctxt->sc), ctxt->sc->cache_config,
488 APR_DBM_RWCREATE, SSL_DBM_FILE_MODE, ctxt->c->pool); 494 APR_DBM_RWCREATE, SSL_DBM_FILE_MODE, ctxt->c->pool);
489 if (rv != APR_SUCCESS) { 495 if (rv != APR_SUCCESS) {
490 ap_log_error(APLOG_MARK, APLOG_NOTICE, rv, 496 ap_log_error(APLOG_MARK, APLOG_NOTICE, rv,
@@ -518,7 +524,7 @@ static int dbm_cache_post_config(apr_pool_t *p, server_rec *s,
518 const char* path1; 524 const char* path1;
519 const char* path2; 525 const char* path2;
520 526
521 rv = apr_dbm_open_ex(&dbm, ODB, sc->cache_config, APR_DBM_RWCREATE, 527 rv = apr_dbm_open_ex(&dbm, db_type(sc), sc->cache_config, APR_DBM_RWCREATE,
522 SSL_DBM_FILE_MODE, p); 528 SSL_DBM_FILE_MODE, p);
523 529
524 if (rv != APR_SUCCESS) { 530 if (rv != APR_SUCCESS) {
@@ -530,7 +536,7 @@ static int dbm_cache_post_config(apr_pool_t *p, server_rec *s,
530 536
531 apr_dbm_close(dbm); 537 apr_dbm_close(dbm);
532 538
533 apr_dbm_get_usednames_ex(p, ODB, sc->cache_config, &path1, &path2); 539 apr_dbm_get_usednames_ex(p, db_type(sc), sc->cache_config, &path1, &path2);
534 540
535 /* The Following Code takes logic directly from mod_ssl's DBM Cache */ 541 /* The Following Code takes logic directly from mod_ssl's DBM Cache */
536#if !defined(OS2) && !defined(WIN32) && !defined(BEOS) && !defined(NETWARE) 542#if !defined(OS2) && !defined(WIN32) && !defined(BEOS) && !defined(NETWARE)
@@ -549,7 +555,7 @@ static int dbm_cache_post_config(apr_pool_t *p, server_rec *s,
549int mgs_cache_post_config(apr_pool_t *p, server_rec *s, 555int mgs_cache_post_config(apr_pool_t *p, server_rec *s,
550 mgs_srvconf_rec *sc) 556 mgs_srvconf_rec *sc)
551{ 557{
552 if (sc->cache_type == mgs_cache_dbm) { 558 if (sc->cache_type == mgs_cache_dbm || sc->cache_type == mgs_cache_sdbm) {
553 return dbm_cache_post_config(p, s, sc); 559 return dbm_cache_post_config(p, s, sc);
554 } 560 }
555 return 0; 561 return 0;
@@ -558,7 +564,7 @@ int mgs_cache_post_config(apr_pool_t *p, server_rec *s,
558int mgs_cache_child_init(apr_pool_t *p, server_rec *s, 564int mgs_cache_child_init(apr_pool_t *p, server_rec *s,
559 mgs_srvconf_rec *sc) 565 mgs_srvconf_rec *sc)
560{ 566{
561 if (sc->cache_type == mgs_cache_dbm) { 567 if (sc->cache_type == mgs_cache_dbm || sc->cache_type == mgs_cache_sdbm) {
562 return 0; 568 return 0;
563 } 569 }
564#if HAVE_APR_MEMCACHE 570#if HAVE_APR_MEMCACHE
@@ -573,7 +579,7 @@ int mgs_cache_child_init(apr_pool_t *p, server_rec *s,
573 579
574int mgs_cache_session_init(mgs_handle_t *ctxt) 580int mgs_cache_session_init(mgs_handle_t *ctxt)
575{ 581{
576 if (ctxt->sc->cache_type == mgs_cache_dbm) { 582 if (ctxt->sc->cache_type == mgs_cache_dbm || ctxt->sc->cache_type == mgs_cache_sdbm) {
577 gnutls_db_set_retrieve_function(ctxt->session, dbm_cache_fetch); 583 gnutls_db_set_retrieve_function(ctxt->session, dbm_cache_fetch);
578 gnutls_db_set_remove_function(ctxt->session, dbm_cache_delete); 584 gnutls_db_set_remove_function(ctxt->session, dbm_cache_delete);
579 gnutls_db_set_store_function(ctxt->session, dbm_cache_store); 585 gnutls_db_set_store_function(ctxt->session, dbm_cache_store);
diff --git a/src/gnutls_config.c b/src/gnutls_config.c
index 6c8d427..4bb523f 100644
--- a/src/gnutls_config.c
+++ b/src/gnutls_config.c
@@ -343,10 +343,14 @@ const char *mgs_set_cache(cmd_parms * parms, void *dummy,
343 return err; 343 return err;
344 } 344 }
345 345
346 sc->cache_type = mgs_cache_none; 346 if (strcasecmp("none", type) == 0) {
347 if (strcasecmp("dbm", type) == 0) { 347 sc->cache_type = mgs_cache_none;
348 } else if (strcasecmp("dbm", type) == 0) {
348 sc->cache_type = mgs_cache_dbm; 349 sc->cache_type = mgs_cache_dbm;
349 } 350 }
351 else if (strcasecmp("sdbm", type) == 0) {
352 sc->cache_type = mgs_cache_sdbm;
353 }
350#if HAVE_APR_MEMCACHE 354#if HAVE_APR_MEMCACHE
351 else if (strcasecmp("memcache", type) == 0) { 355 else if (strcasecmp("memcache", type) == 0) {
352 sc->cache_type = mgs_cache_memcache; 356 sc->cache_type = mgs_cache_memcache;
@@ -356,7 +360,7 @@ const char *mgs_set_cache(cmd_parms * parms, void *dummy,
356 return "Invalid Type for GnuTLSCache!"; 360 return "Invalid Type for GnuTLSCache!";
357 } 361 }
358 362
359 if (sc->cache_type == mgs_cache_dbm) { 363 if (sc->cache_type == mgs_cache_dbm || sc->cache_type == mgs_cache_sdbm) {
360 sc->cache_config = ap_server_root_relative(parms->pool, arg); 364 sc->cache_config = ap_server_root_relative(parms->pool, arg);
361 } else { 365 } else {
362 sc->cache_config = apr_pstrdup(parms->pool, arg); 366 sc->cache_config = apr_pstrdup(parms->pool, arg);