/*
- * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
+ * Copyright (C) 2005-2009 Atsushi Konno All rights reserved.
* Copyright (C) 2005 QSDN,Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
apr_dbm_t *f;
apr_file_t *file;
- DBG(r, "start chxj_save_cookie_dbm() cookie_id:[%s]", cookie_id);
+ DBG(r, "REQ[%X] start chxj_save_cookie_dbm() cookie_id:[%s]", TO_ADDR(r), cookie_id);
file = chxj_cookie_db_lock(r);
if (! file) {
- ERR(r, "mod_chxj: Can't lock cookie db");
- DBG(r, "end chxj_save_cookie_dbm() cookie_id:[%s]", cookie_id);
+ ERR(r, "%s:%d REQ[%X] mod_chxj: Can't lock cookie db", __FILE__,__LINE__,TO_ADDR(r));
+ DBG(r, "REQ[%X] end chxj_save_cookie_dbm() cookie_id:[%s]", TO_ADDR(r), cookie_id);
return CHXJ_FALSE;
}
retval = apr_dbm_open_ex(&f,
- "default",
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
chxj_cookie_db_name_create(r, m->cookie_db_dir),
APR_DBM_RWCREATE,
APR_OS_DEFAULT,
r->pool);
if (retval != APR_SUCCESS) {
- ERR(r, "could not open dbm (type %s) auth file: %s",
- "default",
- chxj_cookie_db_name_create(r,m->cookie_db_dir));
+ char errstr[256];
+ ERR(r, "%s:%d could not open dbm (type %s) auth file: %s(%d:%s)",
+ __FILE__,
+ __LINE__,
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
+ chxj_cookie_db_name_create(r,m->cookie_db_dir),
+ retval,
+ apr_strerror(retval, errstr, 255));
chxj_cookie_db_unlock(r, file);
- DBG(r, "end chxj_save_cookie_dbm() cookie_id:[%s]", cookie_id);
+ DBG(r, "REQ[%X] end chxj_save_cookie_dbm() cookie_id:[%s]", TO_ADDR(r), cookie_id);
return CHXJ_FALSE;
}
*/
retval = apr_dbm_store(f, dbmkey, dbmval);
if (retval != APR_SUCCESS) {
- ERR(r, "Cannot store Cookie data to DBM file `%s'",
- chxj_cookie_db_name_create(r, m->cookie_db_dir));
+ char errstr[256];
+ ERR(r, "%s:%d Cannot store Cookie data to DBM file `%s' tye:[%s] (%d:%s) key:[%s] val:[%s]",
+ __FILE__,
+ __LINE__,
+ chxj_cookie_db_name_create(r, m->cookie_db_dir),
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
+ retval,
+ apr_strerror(retval, errstr, 255),
+ dbmkey.dptr,
+ dbmval.dptr);
apr_dbm_close(f);
chxj_cookie_db_unlock(r, file);
- DBG(r, "end chxj_save_cookie_dbm() cookie_id:[%s]", cookie_id);
+ DBG(r, "REQ[%X] end chxj_save_cookie_dbm() cookie_id:[%s]", TO_ADDR(r), cookie_id);
return CHXJ_FALSE;
}
apr_dbm_close(f);
chxj_cookie_db_unlock(r, file);
- DBG(r, "end chxj_save_cookie_dbm() cookie_id:[%s]", cookie_id);
+ DBG(r, "REQ[%X] end chxj_save_cookie_dbm() cookie_id:[%s]", TO_ADDR(r), cookie_id);
return CHXJ_TRUE;
}
apr_status_t rv;
mod_chxj_config *dconf;
- dconf = (mod_chxj_config*)ap_get_module_config(r->per_dir_config, &chxj_module);
+ dconf = (mod_chxj_config*)chxj_get_module_config(r->per_dir_config, &chxj_module);
rv = apr_file_open(&file,
chxj_cookie_db_lock_name_create(r, dconf->cookie_db_dir),
chxj_cookie_db_lock_name_create(request_rec *r, const char *dir)
{
char *dst;
- DBG(r, "start chxj_cookie_db_lock_name_create()");
+ DBG(r, "REQ[%X] start chxj_cookie_db_lock_name_create()", TO_ADDR(r));
if (!dir) {
- DBG(r, " ");
dst = apr_pstrdup(r->pool, DEFAULT_COOKIE_DB_DIR);
- DBG(r, " ");
}
else {
dst = apr_pstrdup(r->pool, dir);
- DBG(r, " ");
}
- DBG(r, "dst[strlen(dst)-1]=[%c]", dst[strlen(dst)-1]);
if (dst[strlen(dst)-1] != '/') {
dst = apr_pstrcat(r->pool, dst, "/", COOKIE_DB_LOCK_NAME, NULL);
}
else {
dst = apr_pstrcat(r->pool, dst, COOKIE_DB_LOCK_NAME, NULL);
}
- DBG(r, "end chxj_cookie_db_lock_name_create()");
+ DBG(r, "REQ[%X] end chxj_cookie_db_lock_name_create()", TO_ADDR(r));
return dst;
}
apr_status_t rv;
mod_chxj_config *dconf;
- dconf = (mod_chxj_config *)ap_get_module_config(r->per_dir_config, &chxj_module);
+ dconf = (mod_chxj_config *)chxj_get_module_config(r->per_dir_config, &chxj_module);
rv = apr_file_open(&file,
chxj_cookie_expire_db_lock_name_create(r, dconf->cookie_db_dir),
}
retval = apr_dbm_open_ex(&f,
- "default",
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
chxj_cookie_db_name_create(r, m->cookie_db_dir),
APR_DBM_RWCREATE,
APR_OS_DEFAULT,
r->pool);
if (retval != APR_SUCCESS) {
ERR(r, "could not open dbm (type %s) auth file: %s",
- "default",
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
chxj_cookie_db_name_create(r,m->cookie_db_dir));
chxj_cookie_db_unlock(r, file);
DBG(r, "end chxj_update_cookie_dbm() cookie_id:[%s]", cookie_id);
*/
retval = apr_dbm_store(f, dbmkey, dbmval);
if (retval != APR_SUCCESS) {
- ERR(r, "Cannot store Cookie data to DBM file `%s'",
- chxj_cookie_db_name_create(r, m->cookie_db_dir));
+ char errstr[256];
+ ERR(r, "%s:%d Cannot store Cookie data to DBM file `%s' tye:[%s] (%d:%s) key:[%s] val:[%s]",
+ __FILE__,
+ __LINE__,
+ chxj_cookie_db_name_create(r, m->cookie_db_dir),
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
+ retval,
+ apr_strerror(retval, errstr, 255),
+ dbmkey.dptr,
+ dbmval.dptr);
apr_dbm_close(f);
chxj_cookie_db_unlock(r, file);
DBG(r, "end chxj_update_cookie_dbm() cookie_id:[%s]", cookie_id);
apr_datum_t dbmval;
apr_datum_t dbmkey;
- DBG(r, "start chxj_load_cookie_dbm() cookie_id:[%s]", cookie_id);
+ DBG(r, "REQ[%X] start chxj_load_cookie_dbm() cookie_id:[%s]", TO_ADDR(r), cookie_id);
file = chxj_cookie_db_lock(r);
if (! file) {
- ERR(r, "mod_chxj: Can't lock cookie db");
- DBG(r, "end chxj_load_cookie_dbm() cookie_id:[%s]", cookie_id);
+ ERR(r, "REQ[%X] mod_chxj: Can't lock cookie db", TO_ADDR(r));
+ DBG(r, "REQ[%X] end chxj_load_cookie_dbm() cookie_id:[%s]", TO_ADDR(r), cookie_id);
return NULL;
}
retval = apr_dbm_open_ex(&f,
- "default",
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
chxj_cookie_db_name_create(r, m->cookie_db_dir),
APR_DBM_RWCREATE,
APR_OS_DEFAULT,
r->pool);
if (retval != APR_SUCCESS) {
+ char errstr[256];
ERR(r,
- "could not open dbm (type %s) auth file: %s",
- "default",
- chxj_cookie_db_name_create(r, m->cookie_db_dir));
+ "%s:%d could not open dbm (type %s) auth file: %s (%d:%s)",
+ __FILE__,
+ __LINE__,
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
+ chxj_cookie_db_name_create(r, m->cookie_db_dir),
+ retval,
+ apr_strerror(retval, errstr, 255));
chxj_cookie_db_unlock(r, file);
- DBG(r, "end chxj_load_cookie_dbm() cookie_id:[%s]", cookie_id);
+ DBG(r, "TO_REQ[%X] end chxj_load_cookie_dbm() cookie_id:[%s]", TO_ADDR(r), cookie_id);
return NULL;
}
if (apr_dbm_exists(f, dbmkey)) {
retval = apr_dbm_fetch(f, dbmkey, &dbmval);
if (retval != APR_SUCCESS) {
+ char errstr[256];
ERR(r,
- "could not fetch dbm (type %s) auth file: %s", "default",
- chxj_cookie_db_name_create(r, m->cookie_db_dir));
+ "%s:%d could not fetch dbm (type %s) auth file: %s(%d:%s)",
+ __FILE__,
+ __LINE__,
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
+ chxj_cookie_db_name_create(r, m->cookie_db_dir),
+ retval,
+ apr_strerror(retval, errstr, 255));
apr_dbm_close(f);
chxj_cookie_db_unlock(r, file);
- DBG(r, "end chxj_load_cookie_dbm() cookie_id:[%s]", cookie_id);
+ DBG(r, "REQ[%X] end chxj_load_cookie_dbm() cookie_id:[%s]", TO_ADDR(r), cookie_id);
return NULL;
}
load_string = apr_palloc(r->pool, dbmval.dsize+1);
memset(load_string, 0, dbmval.dsize+1);
memcpy(load_string, dbmval.dptr, dbmval.dsize);
}
+ else {
+ DBG(r, "REQ[%X] Not Found cookie_id:[%s]", TO_ADDR(r), cookie_id);
+ load_string = apr_pstrdup(r->pool, "");
+ }
apr_dbm_close(f);
chxj_cookie_db_unlock(r, file);
- DBG(r, "end chxj_load_cookie_dbm() cookie_id:[%s]", cookie_id);
+ DBG(r, "REQ[%X] end chxj_load_cookie_dbm() cookie_id:[%s]", TO_ADDR(r), cookie_id);
return load_string;
}
apr_status_t retval;
apr_file_t *file;
apr_datum_t dbmkey;
- apr_dbm_t* f;
+ apr_dbm_t *f;
DBG(r, "start chxj_delete_cookie_dbm() cookie_id:[%s]", cookie_id);
file = chxj_cookie_db_lock(r);
}
retval = apr_dbm_open_ex(&f,
- "default",
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
chxj_cookie_db_name_create(r, m->cookie_db_dir),
APR_DBM_RWCREATE,
APR_OS_DEFAULT,
if (retval != APR_SUCCESS) {
ERR(r,
"could not open dbm (type %s) auth file: %s",
- "default",
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
chxj_cookie_db_name_create(r,m->cookie_db_dir));
chxj_cookie_db_unlock(r, file);
DBG(r, "end chxj_delete_cookie_dbm() cookie_id:[%s]", cookie_id);
apr_file_t *file;
apr_datum_t dbmkey;
apr_datum_t dbmval;
- apr_dbm_t* f;
+ apr_dbm_t *f;
DBG(r, "start chxj_save_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
file = chxj_cookie_expire_db_lock(r);
return CHXJ_FALSE;
}
- DBG(r, " ");
-
retval = apr_dbm_open_ex(&f,
- "default",
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
chxj_cookie_expire_db_name_create(r, m->cookie_db_dir),
APR_DBM_RWCREATE,
APR_OS_DEFAULT,
r->pool);
if (retval != APR_SUCCESS) {
ERR(r, "could not open dbm (type %s) auth file: %s",
- "default",
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
chxj_cookie_expire_db_name_create(r,m->cookie_db_dir));
chxj_cookie_expire_db_unlock(r, file);
DBG(r, "end chxj_save_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
{
apr_status_t retval;
apr_datum_t dbmkey;
- apr_dbm_t* f;
- apr_file_t* file;
+ apr_dbm_t *f;
+ apr_file_t *file;
DBG(r, "start chxj_delete_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
file = chxj_cookie_expire_db_lock(r);
return CHXJ_FALSE;
}
retval = apr_dbm_open_ex(&f,
- "default",
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
chxj_cookie_expire_db_name_create(r, m->cookie_db_dir),
APR_DBM_RWCREATE,
APR_OS_DEFAULT,
if (retval != APR_SUCCESS) {
ERR(r,
"could not open dbm (type %s) auth file: %s",
- "default",
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
chxj_cookie_expire_db_name_create(r,m->cookie_db_dir));
chxj_cookie_expire_db_unlock(r, file);
DBG(r, "end chxj_delete_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
apr_status_t retval;
apr_datum_t dbmkey;
apr_datum_t dbmval;
- apr_dbm_t* f;
- apr_file_t* file;
+ apr_dbm_t *f;
+ apr_file_t *file;
time_t now_time;
DBG(r, "start chxj_cookie_expire_gc_dbm()");
}
retval = apr_dbm_open_ex(&f,
- "default",
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
chxj_cookie_expire_db_name_create(r, m->cookie_db_dir),
APR_DBM_RWCREATE,
APR_OS_DEFAULT,
if (retval != APR_SUCCESS) {
ERR(r,
"could not open dbm (type %s) auth file: %s",
- "default",
+ (m->cookie_dbm_type) ? m->cookie_dbm_type : "default",
chxj_cookie_expire_db_name_create(r,m->cookie_db_dir));
chxj_cookie_expire_db_unlock(r, file);
DBG(r, "end chxj_cookie_expire_gc_dbm()");
DBG(r, "end chxj_cookie_expire_gc_dbm()");
return CHXJ_TRUE;
}
+
+
+cookie_lock_t *
+chxj_cookie_lock_dbm(request_rec *r, mod_chxj_config *UNUSED(m))
+{
+ cookie_lock_t *ret = apr_palloc(r->pool, sizeof(*ret));
+ ret->file = chxj_cookie_db_lock(r);
+ return ret;
+}
+
+
+int
+chxj_cookie_unlock_dbm(request_rec *r, cookie_lock_t *lock, mod_chxj_config *UNUSED(m))
+{
+ chxj_cookie_expire_db_unlock(r, lock->file);
+ return 1; /* allways true */
+}
/*
* vim:ts=2 et
*/