apr_array_header_t* cookie_headers;
};
+typedef struct cookie_lock_t cookie_lock_t;
+
+struct cookie_lock_t {
+ apr_file_t *file;
+};
+
+
extern cookie_t* chxj_save_cookie(
request_rec* r);
cookie_t* old_cookie);
extern apr_time_t chxj_parse_cookie_expires(const char *s);
-extern int chxj_cookie_lock(request_rec *r);
-extern int chxj_cookie_unlock(request_rec *r);
+
+extern cookie_lock_t *__chxj_cookie_lock(request_rec *r, const char *filename, int line);
+extern int __chxj_cookie_unlock(request_rec *r, cookie_lock_t *lock, const char *filename, int line);
+
+#define chxj_cookie_lock(X) __chxj_cookie_lock((X),__FILE__,__LINE__)
+#define chxj_cookie_unlock(X,L) __chxj_cookie_unlock((X),(L),__FILE__,__LINE__)
+
#endif
/*
* vim:ts=2 et
extern int chxj_save_cookie_expire_dbm(request_rec *r, mod_chxj_config *m, const char *cookie_id);
extern int chxj_delete_cookie_expire_dbm(request_rec *r, mod_chxj_config *m, const char *cookie_id);
extern int chxj_cookie_expire_gc_dbm(request_rec *r, mod_chxj_config *m);
-extern int chxj_cookie_lock_dbm(request_rec *r, mod_chxj_config *m);
-extern int chxj_cookie_unlock_dbm(request_rec *r, mod_chxj_config *m);
+extern cookie_lock_t *chxj_cookie_lock_dbm(request_rec *r, mod_chxj_config *UNUSED(m));
+extern int chxj_cookie_unlock_dbm(request_rec *r, cookie_lock_t *lock, mod_chxj_config *UNUSED(m));
#endif
}
-int
-chxj_cookie_lock(request_rec *r)
+cookie_lock_t *
+__chxj_cookie_lock(request_rec *r, const char *filename, int line)
{
mod_chxj_config *dconf;
apr_status_t rv;
int done_proc = 0;
+ cookie_lock_t *ret = NULL;
- DBG(r, "start chxj_cookie_lock()");
+ DBG(r, "start chxj_cookie_lock() call from %s:%d", filename, line);
if ((rv = apr_proc_mutex_lock(global_cookie_mutex)) != APR_SUCCESS) {
char errstr[255];
ERR(r, "%s:%d apr_proc_mutex_lock failure.(%d:%s)", APLOG_MARK, rv, apr_strerror(rv, errstr, 255));
- return 0;
+ return NULL;
}
dconf = chxj_get_module_config(r->per_dir_config, &chxj_module);
#if defined(USE_MYSQL_COOKIE)
if (IS_COOKIE_STORE_MYSQL(dconf->cookie_store_type)) {
if (! chxj_cookie_lock_mysql(r, dconf)) {
ERR(r, "%s:%d end chxj_cookie_lock(): failed: chxj_cookie_lock_mysql()", APLOG_MARK);
- return 0;
+ return NULL;
}
done_proc = 1;
- }
+ ret = apr_palloc(r->pool, sizeof(*ret));
+ memset(ret, 0, sizeof(*ret));
+ }
#endif
#if defined(USE_MEMCACHE_COOKIE)
if (IS_COOKIE_STORE_MEMCACHE(dconf->cookie_store_type)) {
if (! chxj_cookie_lock_memcache(r, dconf)) {
ERR(r, "%s:%d end chxj_cookie_lock(): failed: chxj_cookie_lock_memcache()", APLOG_MARK);
- return 0;
+ return NULL;
}
done_proc = 1;
- }
+ ret = apr_palloc(r->pool, sizeof(*ret));
+ memset(ret, 0, sizeof(*ret));
+ }
#endif
if (!done_proc) {
- if (! chxj_cookie_lock_dbm(r, dconf)) {
+ if (!(ret = chxj_cookie_lock_dbm(r, dconf))) {
ERR(r, "%s:%d end chxj_cookie_lock(): failed: chxj_cookie_lock_dbm()", APLOG_MARK);
- return 0;
+ DBG(r, "end chxj_cookie_lock() call from %s:%d", filename, line);
+ return NULL;
}
}
- DBG(r, "end chxj_cookie_lock()");
- return 1;
+ DBG(r, "REQ:[%X] end chxj_cookie_lock() call from %s:%d", (unsigned int)(apr_size_t)r, filename, line);
+ return ret;
}
int
-chxj_cookie_unlock(request_rec *r)
+__chxj_cookie_unlock(request_rec *r, cookie_lock_t *lock, const char *filename, int line)
{
mod_chxj_config *dconf;
int done_proc = 0;
apr_status_t rv;
int rtn = 1;
- DBG(r, "start chxj_cookie_unlock()");
+ DBG(r, "start chxj_cookie_unlock() call from %s:%d", filename, line);
dconf = chxj_get_module_config(r->per_dir_config, &chxj_module);
#if defined(USE_MYSQL_COOKIE)
goto end_chxj_cookie_unlock;
}
done_proc = 1;
- }
+ }
#endif
#if defined(USE_MEMCACHE_COOKIE)
if (IS_COOKIE_STORE_MEMCACHE(dconf->cookie_store_type)) {
goto end_chxj_cookie_unlock;
}
done_proc = 1;
- }
+ }
#endif
if (!done_proc) {
- if (! chxj_cookie_unlock_dbm(r, dconf)) {
+ if (! chxj_cookie_unlock_dbm(r, lock, dconf)) {
ERR(r, "failed: chxj_cookie_unlock_dbm()");
rtn = 0;
goto end_chxj_cookie_unlock;
if ((rv = apr_proc_mutex_unlock(global_cookie_mutex)) != APR_SUCCESS) {
char errstr[255];
ERR(r, "%s:%d apr_proc_mutex_unlock failure.(%d:%s)", APLOG_MARK, rv, apr_strerror(rv, errstr, 255));
+ DBG(r, "end chxj_cookie_unlock() call from %s:%d", filename, line);
return 0;
}
- DBG(r, "end chxj_cookie_unlock()");
+ DBG(r, "end chxj_cookie_unlock() call from %s:%d", filename, line);
return rtn;
}
}
-int
-chxj_cookie_lock_dbm(request_rec *UNUSED(r), mod_chxj_config *UNUSED(m))
+cookie_lock_t *
+chxj_cookie_lock_dbm(request_rec *r, mod_chxj_config *UNUSED(m))
{
- return 1; /* allways true */
+ 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 *UNUSED(r), mod_chxj_config *UNUSED(m))
+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 */
}
/*
apr_table_unset(r->headers_in, "Cookie");
DBG(r, "found cookie parameter[%s]", value);
DBG(r, "call start chxj_load_cookie()");
- chxj_cookie_lock(r);
+ cookie_lock_t *lock = chxj_cookie_lock(r);
cookie = chxj_load_cookie(r, value);
DBG(r, "call end chxj_load_cookie()");
if (! no_update_flag && cookie) {
chxj_update_cookie(r, cookie);
}
- chxj_cookie_unlock(r);
+ chxj_cookie_unlock(r, lock);
}
}
r->args = result;
DBG(r, "not convert content-type:[%s] dconf->image:[%d]", r->content_type, dconf->image);
if (entryp->action & CONVRULE_COOKIE_ON_BIT) {
+ cookie_lock_t *lock = NULL;
DBG(r, "entryp->action == COOKIE_ON_BIT");
switch(spec->html_spec_type) {
case CHXJ_SPEC_Chtml_1_0:
case CHXJ_SPEC_Chtml_7_0:
case CHXJ_SPEC_XHtml_Mobile_1_0:
case CHXJ_SPEC_Jhtml:
- chxj_cookie_lock(r);
+ lock = chxj_cookie_lock(r);
cookie = chxj_save_cookie(r);
s_add_cookie_id_if_has_location_header(r, cookie);
- chxj_cookie_unlock(r);
+ chxj_cookie_unlock(r, lock);
break;
default:
break;
/* End Of File */
/*----------------------------------------------------------------------*/
if (ctx) {
+ cookie_lock_t *lock = NULL;
ctx = (mod_chxj_ctx *)f->ctx;
DBG(r, "content_type=[%s]", r->content_type);
- chxj_cookie_lock(r);
+ lock = chxj_cookie_lock(r);
if (spec->html_spec_type != CHXJ_SPEC_UNKNOWN
&& r->content_type
sts = chxj_qrcode_create_image_data(&qrcode, &ctx->buffer, &ctx->len);
if (sts != OK) {
ERR(r, "qrcode create failed.");
- chxj_cookie_unlock(r);
+ chxj_cookie_unlock(r, lock);
return sts;
}
r->content_type = apr_psprintf(r->pool, "image/jpeg");
if (ctx->len > 0) {
DBG(r, "call pass_data_to_filter()");
s_add_cookie_id_if_has_location_header(r, cookie);
- chxj_cookie_unlock(r);
+ chxj_cookie_unlock(r,lock);
rv = pass_data_to_filter(f,
(const char *)ctx->buffer,
(apr_size_t)ctx->len);
}
else {
- chxj_cookie_unlock(r);
+ chxj_cookie_unlock(r, lock);
+
}
return rv;
}
* save cookie.
*/
if (entryp->action & CONVRULE_COOKIE_ON_BIT) {
+ cookie_lock_t *lock = NULL;
DBG(r, "entryp->action == COOKIE_ON_BIT");
switch(spec->html_spec_type) {
case CHXJ_SPEC_Chtml_1_0:
case CHXJ_SPEC_Chtml_7_0:
case CHXJ_SPEC_XHtml_Mobile_1_0:
case CHXJ_SPEC_Jhtml:
- chxj_cookie_lock(r);
+ lock = chxj_cookie_lock(r);
cookie = chxj_save_cookie(r);
/*
* Location Header Check to add cookie parameter.
*/
s_add_cookie_id_if_has_location_header(r, cookie);
- chxj_cookie_unlock(r);
+ chxj_cookie_unlock(r, lock);
apr_table_unset(r->headers_out, "Set-Cookie");
apr_table_unset(r->err_headers_out, "Set-Cookie");
break;