OSDN Git Service

Merge branch 'master' into branch_0.13.0
[modchxj/mod_chxj.git] / src / chxj_dbm.c
1 /*
2  * Copyright (C) 2005-2009 Atsushi Konno All rights reserved.
3  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #include "mod_chxj.h"
18 #include "chxj_cookie.h"
19 #include "chxj_dbm.h"
20 #include "chxj_url_encode.h"
21 #include "chxj_apply_convrule.h"
22 #include "chxj_str_util.h"
23
24 #include "ap_release.h"
25
26 #include "apu.h"
27 #include "apr_uuid.h"
28 #include "apr_md5.h"
29 #include "apr_base64.h"
30 #include "apr_uri.h"
31
32 #include <unistd.h>
33
34 int
35 chxj_save_cookie_dbm(request_rec *r, mod_chxj_config *m, const char *cookie_id, const char *store_string)
36 {
37   apr_status_t        retval;
38   apr_datum_t         dbmkey;
39   apr_datum_t         dbmval;
40   apr_dbm_t           *f;
41   apr_file_t          *file;
42
43   DBG(r, "start chxj_save_cookie_dbm() cookie_id:[%s]", cookie_id);
44
45   file = chxj_cookie_db_lock(r);
46   if (! file) {
47     ERR(r, "mod_chxj: Can't lock cookie db");
48     DBG(r, "end chxj_save_cookie_dbm() cookie_id:[%s]", cookie_id);
49     return CHXJ_FALSE;
50   }
51
52   retval = apr_dbm_open_ex(&f,
53                            "default",
54                            chxj_cookie_db_name_create(r, m->cookie_db_dir),
55                            APR_DBM_RWCREATE,
56                            APR_OS_DEFAULT,
57                            r->pool);
58   if (retval != APR_SUCCESS) {
59     char errstr[256];
60     ERR(r, "%s:%d could not open dbm (type %s) auth file: %s(%d:%s)",
61             __FILE__,
62             __LINE__,
63             "default",
64             chxj_cookie_db_name_create(r,m->cookie_db_dir),
65             retval,
66             apr_strerror(retval, errstr, 255));
67     chxj_cookie_db_unlock(r, file);
68     DBG(r, "end chxj_save_cookie_dbm() cookie_id:[%s]", cookie_id);
69     return CHXJ_FALSE;
70   }
71
72
73   /*
74    * create key
75    */
76
77   dbmkey.dptr  = apr_pstrdup(r->pool, cookie_id);
78   dbmkey.dsize = strlen(cookie_id);
79   dbmval.dptr  = apr_pstrdup(r->pool, store_string);
80   dbmval.dsize = strlen(store_string);
81
82   /*
83    * store to db
84    */
85   retval = apr_dbm_store(f, dbmkey, dbmval);
86   if (retval != APR_SUCCESS) {
87     char errstr[256];
88     ERR(r, "%s:%d Cannot store Cookie data to DBM file `%s' (%d:%s)",
89             __FILE__,
90             __LINE__,
91             chxj_cookie_db_name_create(r, m->cookie_db_dir),
92             retval,
93             apr_strerror(retval, errstr, 255));
94     apr_dbm_close(f);
95     chxj_cookie_db_unlock(r, file);
96     DBG(r, "end chxj_save_cookie_dbm() cookie_id:[%s]", cookie_id);
97     return CHXJ_FALSE;
98   }
99
100   apr_dbm_close(f);
101   chxj_cookie_db_unlock(r, file);
102   DBG(r, "end chxj_save_cookie_dbm() cookie_id:[%s]", cookie_id);
103   return CHXJ_TRUE;
104 }
105
106
107 void
108 chxj_cookie_db_unlock(request_rec *r, apr_file_t *file)
109 {
110   apr_status_t rv;
111
112   rv = apr_file_unlock(file);
113   if (rv != APR_SUCCESS) {
114     ERR(r, "cookie lock file open failed.");
115     return;
116   }
117
118   apr_file_close(file);
119 }
120
121
122 apr_file_t *
123 chxj_cookie_db_lock(request_rec *r)
124 {
125   apr_file_t       *file;
126   apr_status_t     rv;
127   mod_chxj_config  *dconf;
128
129   dconf = (mod_chxj_config*)chxj_get_module_config(r->per_dir_config, &chxj_module);
130
131   rv = apr_file_open(&file,
132                      chxj_cookie_db_lock_name_create(r, dconf->cookie_db_dir),
133                      APR_CREATE|APR_WRITE,
134                      APR_OS_DEFAULT,
135                      r->pool);
136   if (rv != APR_SUCCESS) {
137     ERR(r, "cookie lock file open failed.");
138     return NULL;
139   }
140
141   rv = apr_file_lock(file,APR_FLOCK_EXCLUSIVE);
142   if (rv != APR_SUCCESS) {
143     ERR(r, "cookie lock file open failed.");
144     apr_file_close(file);
145     return NULL;
146   }
147
148   return file;
149 }
150
151
152 char *
153 chxj_cookie_db_name_create(request_rec *r, const char *dir)
154 {
155   char *dst;
156
157   if (!dir) {
158     dst = apr_pstrdup(r->pool, DEFAULT_COOKIE_DB_DIR);
159   }
160   else {
161     dst = apr_pstrdup(r->pool, dir);
162   }
163
164   if (dst[strlen(dst)-1] != '/') {
165     dst = apr_pstrcat(r->pool, dst, "/", COOKIE_DB_NAME, NULL);
166   }
167   else {
168     dst = apr_pstrcat(r->pool, dst, COOKIE_DB_NAME, NULL);
169   }
170
171   return dst;
172 }
173
174
175 char *
176 chxj_cookie_db_lock_name_create(request_rec *r, const char *dir)
177 {
178   char *dst;
179   DBG(r, "start  chxj_cookie_db_lock_name_create()");
180
181   if (!dir) {
182     DBG(r, " ");
183     dst = apr_pstrdup(r->pool, DEFAULT_COOKIE_DB_DIR);
184     DBG(r, " ");
185   }
186   else {
187     dst = apr_pstrdup(r->pool, dir);
188     DBG(r, " ");
189   }
190   DBG(r, "dst[strlen(dst)-1]=[%c]", dst[strlen(dst)-1]);
191   if (dst[strlen(dst)-1] != '/') {
192     dst = apr_pstrcat(r->pool, dst, "/", COOKIE_DB_LOCK_NAME, NULL);
193   }
194   else {
195     dst = apr_pstrcat(r->pool, dst, COOKIE_DB_LOCK_NAME, NULL);
196   }
197   DBG(r, "end  chxj_cookie_db_lock_name_create()");
198   return dst;
199 }
200
201
202
203 char *
204 chxj_cookie_expire_db_name_create(request_rec *r, const char *dir)
205 {
206   char *dst;
207
208   if (!dir) {
209     dst = apr_pstrdup(r->pool, DEFAULT_COOKIE_DB_DIR);
210   }
211   else {
212     dst = apr_pstrdup(r->pool, dir);
213   }
214
215   if (dst[strlen(dst)-1] != '/') {
216     dst = apr_pstrcat(r->pool, dst, "/", COOKIE_EXPIRE_DB_NAME, NULL);
217   }
218   else {
219     dst = apr_pstrcat(r->pool, dst, COOKIE_EXPIRE_DB_NAME, NULL);
220   }
221
222   return dst;
223 }
224
225
226 char *
227 chxj_cookie_expire_db_lock_name_create(request_rec *r, const char *dir)
228 {
229   char *dst;
230
231   if (!dir) {
232     dst = apr_pstrdup(r->pool, DEFAULT_COOKIE_DB_DIR);
233   }
234   else {
235     dst = apr_pstrdup(r->pool, dir);
236   }
237   if (dst[strlen(dst)-1] != '/') {
238     dst = apr_pstrcat(r->pool, dst, "/", COOKIE_EXPIRE_DB_LOCK_NAME, NULL);
239   }
240   else {
241     dst = apr_pstrcat(r->pool, dst, COOKIE_EXPIRE_DB_LOCK_NAME, NULL);
242   }
243
244   return dst;
245 }
246
247
248 apr_file_t *
249 chxj_cookie_expire_db_lock(request_rec *r)
250 {
251   apr_file_t       *file;
252   apr_status_t     rv;
253   mod_chxj_config  *dconf;
254
255   dconf = (mod_chxj_config *)chxj_get_module_config(r->per_dir_config, &chxj_module);
256
257   rv = apr_file_open(&file, 
258                      chxj_cookie_expire_db_lock_name_create(r, dconf->cookie_db_dir),
259                      APR_CREATE|APR_WRITE, 
260                      APR_OS_DEFAULT, 
261                      r->pool);
262   if (rv != APR_SUCCESS) {
263     ERR(r, "cookie lock file open failed.");
264     return NULL;
265   }
266
267   rv = apr_file_lock(file,APR_FLOCK_EXCLUSIVE);
268   if (rv != APR_SUCCESS) {
269     ERR(r, "cookie lock file open failed.");
270     apr_file_close(file);
271     return NULL;
272   }
273
274   return file;
275 }
276
277
278 void
279 chxj_cookie_expire_db_unlock(request_rec *r, apr_file_t *file)
280 {
281   apr_status_t rv;
282
283   rv = apr_file_unlock(file);
284   if (rv != APR_SUCCESS) {
285     ERR(r, "cookie lock file open failed.");
286     return;
287   }
288
289   apr_file_close(file);
290 }
291
292 int
293 chxj_update_cookie_dbm(request_rec *r, mod_chxj_config *m, const char *cookie_id, const char *store_string)
294 {
295   apr_dbm_t           *f;
296   apr_file_t          *file;
297   apr_datum_t         dbmkey;
298   apr_datum_t         dbmval;
299   apr_status_t        retval;
300
301   DBG(r, "start chxj_update_cookie_dbm() cookie_id:[%s]", cookie_id);
302
303   file = chxj_cookie_db_lock(r);
304   if (! file) {
305     ERR(r, "mod_chxj: Can't lock cookie db");
306     DBG(r, "end   chxj_update_cookie_dbm() cookie_id:[%s]", cookie_id);
307     return CHXJ_FALSE;
308   }
309
310   retval = apr_dbm_open_ex(&f,
311                            "default",
312                            chxj_cookie_db_name_create(r, m->cookie_db_dir),
313                            APR_DBM_RWCREATE,
314                            APR_OS_DEFAULT,
315                            r->pool);
316   if (retval != APR_SUCCESS) {
317     ERR(r, "could not open dbm (type %s) auth file: %s",
318             "default",
319             chxj_cookie_db_name_create(r,m->cookie_db_dir));
320     chxj_cookie_db_unlock(r, file);
321     DBG(r, "end   chxj_update_cookie_dbm() cookie_id:[%s]", cookie_id);
322     return CHXJ_FALSE;
323   }
324
325
326   /*
327    * create key
328    */
329
330   dbmkey.dptr  = apr_pstrdup(r->pool, cookie_id);
331   dbmkey.dsize = strlen(cookie_id);
332
333   /*
334    * create val
335    */
336   dbmval.dptr  = apr_pstrdup(r->pool, store_string);
337   dbmval.dsize = strlen(store_string);
338
339   /*
340    * store to db
341    */
342   retval = apr_dbm_store(f, dbmkey, dbmval);
343   if (retval != APR_SUCCESS) {
344     ERR(r, "Cannot store Cookie data to DBM file `%s'",
345             chxj_cookie_db_name_create(r, m->cookie_db_dir));
346     apr_dbm_close(f);
347     chxj_cookie_db_unlock(r, file);
348     DBG(r, "end   chxj_update_cookie_dbm() cookie_id:[%s]", cookie_id);
349     return CHXJ_FALSE;
350   }
351   apr_dbm_close(f);
352   chxj_cookie_db_unlock(r, file);
353   DBG(r, "end   chxj_update_cookie_dbm() cookie_id:[%s]", cookie_id);
354   return CHXJ_TRUE;
355 }
356
357
358 char *
359 chxj_load_cookie_dbm(request_rec *r, mod_chxj_config *m, const char *cookie_id)
360 {
361   char                    *load_string = NULL;
362   apr_status_t            retval;
363   apr_dbm_t               *f;
364   apr_file_t              *file;
365   apr_datum_t             dbmval;
366   apr_datum_t             dbmkey;
367
368   DBG(r, "start chxj_load_cookie_dbm() cookie_id:[%s]", cookie_id);
369   file = chxj_cookie_db_lock(r);
370   if (! file) {
371     ERR(r, "mod_chxj: Can't lock cookie db");
372     DBG(r, "end   chxj_load_cookie_dbm() cookie_id:[%s]", cookie_id);
373     return NULL;
374   }
375
376   retval = apr_dbm_open_ex(&f,
377                            "default",
378                            chxj_cookie_db_name_create(r, m->cookie_db_dir),
379                            APR_DBM_RWCREATE,
380                            APR_OS_DEFAULT,
381                            r->pool);
382   if (retval != APR_SUCCESS) {
383     ERR(r,
384          "could not open dbm (type %s) auth file: %s",
385          "default",
386          chxj_cookie_db_name_create(r, m->cookie_db_dir));
387     chxj_cookie_db_unlock(r, file);
388     DBG(r, "end   chxj_load_cookie_dbm() cookie_id:[%s]", cookie_id);
389     return NULL;
390   }
391
392   /*
393    * create key
394    */
395   dbmkey.dptr  = apr_pstrdup(r->pool, cookie_id);
396   dbmkey.dsize = strlen(dbmkey.dptr);
397
398   if (apr_dbm_exists(f, dbmkey)) {
399     retval = apr_dbm_fetch(f, dbmkey, &dbmval);
400     if (retval != APR_SUCCESS) {
401       ERR(r,
402            "could not fetch dbm (type %s) auth file: %s", "default",
403            chxj_cookie_db_name_create(r, m->cookie_db_dir));
404       apr_dbm_close(f);
405       chxj_cookie_db_unlock(r, file);
406       DBG(r, "end   chxj_load_cookie_dbm() cookie_id:[%s]", cookie_id);
407       return NULL;
408     }
409     load_string = apr_palloc(r->pool, dbmval.dsize+1);
410
411     memset(load_string, 0, dbmval.dsize+1);
412     memcpy(load_string, dbmval.dptr, dbmval.dsize);
413   }
414   apr_dbm_close(f);
415   chxj_cookie_db_unlock(r, file);
416   DBG(r, "end   chxj_load_cookie_dbm() cookie_id:[%s]", cookie_id);
417   return load_string;
418 }
419
420
421 int
422 chxj_delete_cookie_dbm(request_rec *r, mod_chxj_config *m, const char *cookie_id)
423 {
424   apr_status_t      retval;
425   apr_file_t        *file;
426   apr_datum_t       dbmkey;
427   apr_dbm_t         *f;
428
429   DBG(r, "start chxj_delete_cookie_dbm() cookie_id:[%s]", cookie_id);
430   file = chxj_cookie_db_lock(r);
431   if (! file) {
432     ERR(r, "mod_chxj: Can't lock cookie db");
433     DBG(r, "end   chxj_delete_cookie_dbm() cookie_id:[%s]", cookie_id);
434     return CHXJ_FALSE;
435   }
436
437   retval = apr_dbm_open_ex(&f,
438                            "default",
439                            chxj_cookie_db_name_create(r, m->cookie_db_dir),
440                            APR_DBM_RWCREATE,
441                            APR_OS_DEFAULT,
442                            r->pool);
443   if (retval != APR_SUCCESS) {
444     ERR(r,
445          "could not open dbm (type %s) auth file: %s",
446          "default",
447          chxj_cookie_db_name_create(r,m->cookie_db_dir));
448     chxj_cookie_db_unlock(r, file);
449     DBG(r, "end   chxj_delete_cookie_dbm() cookie_id:[%s]", cookie_id);
450     return CHXJ_FALSE;
451   }
452
453   /*
454    * create key
455    */
456   dbmkey.dptr  = apr_pstrdup(r->pool, cookie_id);
457   dbmkey.dsize = strlen(dbmkey.dptr);
458   if (apr_dbm_exists(f, dbmkey)) {
459     apr_dbm_delete(f, dbmkey);
460   }
461   apr_dbm_close(f);
462   chxj_cookie_db_unlock(r, file);
463   DBG(r, "end   chxj_delete_cookie_dbm() cookie_id:[%s]", cookie_id);
464   return CHXJ_TRUE;
465 }
466
467
468 int
469 chxj_save_cookie_expire_dbm(request_rec *r, mod_chxj_config *m, const char *cookie_id)
470 {
471   apr_status_t            retval;
472   char                    *store_string;
473   apr_file_t              *file;
474   apr_datum_t             dbmkey;
475   apr_datum_t             dbmval;
476   apr_dbm_t               *f;
477
478   DBG(r, "start chxj_save_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
479   file = chxj_cookie_expire_db_lock(r);
480   if (! file) {
481     ERR(r, "mod_chxj: Can't lock cookie db");
482     DBG(r, "end   chxj_save_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
483     return CHXJ_FALSE;
484   }
485
486   retval = apr_dbm_open_ex(&f, 
487                            "default", 
488                            chxj_cookie_expire_db_name_create(r, m->cookie_db_dir), 
489                            APR_DBM_RWCREATE, 
490                            APR_OS_DEFAULT, 
491                            r->pool);
492   if (retval != APR_SUCCESS) {
493     ERR(r, "could not open dbm (type %s) auth file: %s", 
494             "default", 
495             chxj_cookie_expire_db_name_create(r,m->cookie_db_dir));
496     chxj_cookie_expire_db_unlock(r, file);
497     DBG(r, "end   chxj_save_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
498     return CHXJ_FALSE;
499   }
500   /*
501    * create key
502    */
503
504   dbmkey.dptr  = apr_pstrdup(r->pool, cookie_id);
505   dbmkey.dsize = strlen(cookie_id);
506
507   /*
508    * create val
509    */
510   
511   store_string = apr_psprintf(r->pool, "%d", (int)time(NULL));
512   dbmval.dptr  = store_string;
513   dbmval.dsize = strlen(store_string);
514
515   /*
516    * store to db
517    */
518   retval = apr_dbm_store(f, dbmkey, dbmval);
519   if (retval != APR_SUCCESS) {
520     ERR(r, "Cannot store Cookie data to DBM file `%s'",
521             chxj_cookie_db_name_create(r, m->cookie_db_dir));
522     DBG(r, "end   chxj_save_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
523     apr_dbm_close(f);
524     chxj_cookie_expire_db_unlock(r, file);
525     return CHXJ_FALSE;
526   }
527
528
529   apr_dbm_close(f);
530   chxj_cookie_expire_db_unlock(r, file);
531   DBG(r, "end   chxj_save_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
532
533   return CHXJ_TRUE;
534 }
535
536
537 int
538 chxj_delete_cookie_expire_dbm(request_rec *r, mod_chxj_config *m, const char *cookie_id)
539 {
540   apr_status_t      retval;
541   apr_datum_t       dbmkey;
542   apr_dbm_t         *f;
543   apr_file_t        *file;
544
545   DBG(r, "start chxj_delete_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
546   file = chxj_cookie_expire_db_lock(r);
547   if (! file) {
548     ERR(r, "mod_chxj: Can't lock cookie db");
549     DBG(r, "end   chxj_delete_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
550     return CHXJ_FALSE;
551   }
552   retval = apr_dbm_open_ex(&f,
553                            "default",
554                            chxj_cookie_expire_db_name_create(r, m->cookie_db_dir),
555                            APR_DBM_RWCREATE,
556                            APR_OS_DEFAULT,
557                            r->pool);
558   if (retval != APR_SUCCESS) {
559     ERR(r,
560          "could not open dbm (type %s) auth file: %s",
561          "default",
562          chxj_cookie_expire_db_name_create(r,m->cookie_db_dir));
563     chxj_cookie_expire_db_unlock(r, file);
564     DBG(r, "end   chxj_delete_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
565     return CHXJ_FALSE;
566   }
567
568   /*
569  *    * create key
570  *       */
571   dbmkey.dptr  = apr_pstrdup(r->pool, cookie_id);
572   dbmkey.dsize = strlen(dbmkey.dptr);
573   if (apr_dbm_exists(f, dbmkey)) {
574     apr_dbm_delete(f, dbmkey);
575   }
576   apr_dbm_close(f);
577   chxj_cookie_expire_db_unlock(r, file);
578   DBG(r, "end   chxj_delete_cookie_expire_dbm() cookie_id:[%s]", cookie_id);
579
580   return CHXJ_TRUE;
581 }
582
583
584 int
585 chxj_cookie_expire_gc_dbm(request_rec *r, mod_chxj_config *m)
586 {
587   apr_status_t      retval;
588   apr_datum_t       dbmkey;
589   apr_datum_t       dbmval;
590   apr_dbm_t         *f;
591   apr_file_t        *file;
592   time_t            now_time;
593
594   DBG(r, "start chxj_cookie_expire_gc_dbm()");
595
596   file = chxj_cookie_expire_db_lock(r);
597   if (! file) {
598     ERR(r, "mod_chxj: Can't lock cookie db");
599     DBG(r, "end   chxj_cookie_expire_gc_dbm()");
600     return CHXJ_FALSE;
601   }
602
603   retval = apr_dbm_open_ex(&f,
604                            "default",
605                            chxj_cookie_expire_db_name_create(r, m->cookie_db_dir),
606                            APR_DBM_RWCREATE,
607                            APR_OS_DEFAULT,
608                            r->pool);
609   if (retval != APR_SUCCESS) {
610     ERR(r, 
611          "could not open dbm (type %s) auth file: %s", 
612          "default", 
613          chxj_cookie_expire_db_name_create(r,m->cookie_db_dir));
614     chxj_cookie_expire_db_unlock(r, file);
615     DBG(r, "end   chxj_cookie_expire_gc_dbm()");
616     return CHXJ_FALSE;
617   }
618
619   /*
620    * create key
621    */
622   memset(&dbmkey, 0, sizeof(apr_datum_t));
623
624   now_time = time(NULL);
625
626   retval = apr_dbm_firstkey(f, &dbmkey);
627   if (retval == APR_SUCCESS) {
628     DBG(r, "firstkey=[%.*s]", (int)dbmkey.dsize, dbmkey.dptr);
629     do {
630       char* tmp;
631       char* old_cookie_id;
632       int   val_time;
633       int   cmp_time;
634
635       retval = apr_dbm_fetch(f, dbmkey, &dbmval);
636       if (retval != APR_SUCCESS) {
637         break;
638       }
639       tmp = apr_palloc(r->pool, dbmval.dsize+1);
640       memset(tmp, 0, dbmval.dsize+1);
641       memcpy(tmp, dbmval.dptr, dbmval.dsize);
642
643
644       val_time = atoi(tmp);
645
646       if (m->cookie_timeout == 0)
647         cmp_time = now_time - DEFAULT_COOKIE_TIMEOUT;
648       else
649         cmp_time = now_time - m->cookie_timeout;
650
651       DBG(r, "m->cookie_timeout=[%d]", (int)m->cookie_timeout);
652       DBG(r, "key=[%.*s] cmp_time=[%d] val_time=[%d]", (int)dbmkey.dsize, dbmkey.dptr, cmp_time, val_time);
653       if (cmp_time >= val_time) {
654         apr_dbm_delete(f, dbmkey);
655
656         old_cookie_id = apr_palloc(r->pool, dbmkey.dsize+1);
657         memset(old_cookie_id, 0, dbmkey.dsize+1);
658         memcpy(old_cookie_id, dbmkey.dptr, dbmkey.dsize);
659
660         chxj_delete_cookie(r,old_cookie_id);
661         DBG(r, "detect timeout cookie [%s]", old_cookie_id);
662       }
663
664       retval = apr_dbm_nextkey(f, &dbmkey);
665     } while(retval == APR_SUCCESS && dbmkey.dptr != NULL);
666   }
667
668   apr_dbm_close(f);
669   chxj_cookie_expire_db_unlock(r, file);
670   DBG(r, "end   chxj_cookie_expire_gc_dbm()");
671   return CHXJ_TRUE;
672 }
673
674
675 cookie_lock_t *
676 chxj_cookie_lock_dbm(request_rec *r, mod_chxj_config *UNUSED(m))
677 {
678   cookie_lock_t *ret = apr_palloc(r->pool, sizeof(*ret));
679   ret->file = chxj_cookie_db_lock(r);
680   return ret;
681 }
682
683
684 int
685 chxj_cookie_unlock_dbm(request_rec *r, cookie_lock_t *lock, mod_chxj_config *UNUSED(m))
686 {
687   chxj_cookie_expire_db_unlock(r, lock->file);
688   return 1; /* allways true */
689 }
690 /*
691  * vim:ts=2 et
692  */