cache separation stuff
This commit is contained in:
parent
b8a0a2a1bb
commit
c8257af1bc
@ -2,4 +2,6 @@ include_HEADERS=containers_public.h queue.h smtp.h cfg.h count.h safe_write.h su
|
|||||||
lib_LTLIBRARIES = libsmmapdfw.la
|
lib_LTLIBRARIES = libsmmapdfw.la
|
||||||
libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c htmalloc.c stats.c htcache.c
|
libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c htmalloc.c stats.c htcache.c
|
||||||
libsmmapdfw_la_LIBADD = @BDB_LIBS@
|
libsmmapdfw_la_LIBADD = @BDB_LIBS@
|
||||||
|
bin_PROGRAMS = htcachetest
|
||||||
|
htcachetest_SOURCES = htcachetest.c
|
||||||
|
htcachetest_LDADD = libsmmapdfw.la
|
||||||
|
@ -91,6 +91,9 @@ include_HEADERS = containers_public.h queue.h smtp.h cfg.h count.h safe_write.h
|
|||||||
lib_LTLIBRARIES = libsmmapdfw.la
|
lib_LTLIBRARIES = libsmmapdfw.la
|
||||||
libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c htmalloc.c stats.c htcache.c
|
libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c htmalloc.c stats.c htcache.c
|
||||||
libsmmapdfw_la_LIBADD = @BDB_LIBS@
|
libsmmapdfw_la_LIBADD = @BDB_LIBS@
|
||||||
|
bin_PROGRAMS = htcachetest
|
||||||
|
htcachetest_SOURCES = htcachetest.c
|
||||||
|
htcachetest_LDADD = libsmmapdfw.la
|
||||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||||
CONFIG_HEADER = ../config.h
|
CONFIG_HEADER = ../config.h
|
||||||
CONFIG_CLEAN_FILES =
|
CONFIG_CLEAN_FILES =
|
||||||
@ -105,6 +108,12 @@ libsmmapdfw_la_LDFLAGS =
|
|||||||
libsmmapdfw_la_DEPENDENCIES =
|
libsmmapdfw_la_DEPENDENCIES =
|
||||||
libsmmapdfw_la_OBJECTS = cfg.lo queue.lo count.lo safe_write.lo \
|
libsmmapdfw_la_OBJECTS = cfg.lo queue.lo count.lo safe_write.lo \
|
||||||
config_public.lo htdns.lo smtp.lo htmalloc.lo stats.lo htcache.lo
|
config_public.lo htdns.lo smtp.lo htmalloc.lo stats.lo htcache.lo
|
||||||
|
bin_PROGRAMS = htcachetest$(EXEEXT)
|
||||||
|
PROGRAMS = $(bin_PROGRAMS)
|
||||||
|
|
||||||
|
htcachetest_OBJECTS = htcachetest.$(OBJEXT)
|
||||||
|
htcachetest_DEPENDENCIES = libsmmapdfw.la
|
||||||
|
htcachetest_LDFLAGS =
|
||||||
CFLAGS = @CFLAGS@
|
CFLAGS = @CFLAGS@
|
||||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
@ -120,10 +129,10 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
|||||||
TAR = tar
|
TAR = tar
|
||||||
GZIP_ENV = --best
|
GZIP_ENV = --best
|
||||||
DEP_FILES = .deps/cfg.P .deps/config_public.P .deps/count.P \
|
DEP_FILES = .deps/cfg.P .deps/config_public.P .deps/count.P \
|
||||||
.deps/htcache.P .deps/htdns.P .deps/htmalloc.P .deps/queue.P \
|
.deps/htcache.P .deps/htcachetest.P .deps/htdns.P .deps/htmalloc.P \
|
||||||
.deps/safe_write.P .deps/smtp.P .deps/stats.P
|
.deps/queue.P .deps/safe_write.P .deps/smtp.P .deps/stats.P
|
||||||
SOURCES = $(libsmmapdfw_la_SOURCES)
|
SOURCES = $(libsmmapdfw_la_SOURCES) $(htcachetest_SOURCES)
|
||||||
OBJECTS = $(libsmmapdfw_la_OBJECTS)
|
OBJECTS = $(libsmmapdfw_la_OBJECTS) $(htcachetest_OBJECTS)
|
||||||
|
|
||||||
all: all-redirect
|
all: all-redirect
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
@ -202,6 +211,35 @@ maintainer-clean-libtool:
|
|||||||
libsmmapdfw.la: $(libsmmapdfw_la_OBJECTS) $(libsmmapdfw_la_DEPENDENCIES)
|
libsmmapdfw.la: $(libsmmapdfw_la_OBJECTS) $(libsmmapdfw_la_DEPENDENCIES)
|
||||||
$(LINK) -rpath $(libdir) $(libsmmapdfw_la_LDFLAGS) $(libsmmapdfw_la_OBJECTS) $(libsmmapdfw_la_LIBADD) $(LIBS)
|
$(LINK) -rpath $(libdir) $(libsmmapdfw_la_LDFLAGS) $(libsmmapdfw_la_OBJECTS) $(libsmmapdfw_la_LIBADD) $(LIBS)
|
||||||
|
|
||||||
|
mostlyclean-binPROGRAMS:
|
||||||
|
|
||||||
|
clean-binPROGRAMS:
|
||||||
|
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
|
||||||
|
|
||||||
|
distclean-binPROGRAMS:
|
||||||
|
|
||||||
|
maintainer-clean-binPROGRAMS:
|
||||||
|
|
||||||
|
install-binPROGRAMS: $(bin_PROGRAMS)
|
||||||
|
@$(NORMAL_INSTALL)
|
||||||
|
$(mkinstalldirs) $(DESTDIR)$(bindir)
|
||||||
|
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||||
|
if test -f $$p; then \
|
||||||
|
echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
|
||||||
|
$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
|
||||||
|
else :; fi; \
|
||||||
|
done
|
||||||
|
|
||||||
|
uninstall-binPROGRAMS:
|
||||||
|
@$(NORMAL_UNINSTALL)
|
||||||
|
list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||||
|
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
|
||||||
|
done
|
||||||
|
|
||||||
|
htcachetest$(EXEEXT): $(htcachetest_OBJECTS) $(htcachetest_DEPENDENCIES)
|
||||||
|
@rm -f htcachetest$(EXEEXT)
|
||||||
|
$(LINK) $(htcachetest_LDFLAGS) $(htcachetest_OBJECTS) $(htcachetest_LDADD) $(LIBS)
|
||||||
|
|
||||||
install-includeHEADERS: $(include_HEADERS)
|
install-includeHEADERS: $(include_HEADERS)
|
||||||
@$(NORMAL_INSTALL)
|
@$(NORMAL_INSTALL)
|
||||||
$(mkinstalldirs) $(DESTDIR)$(includedir)
|
$(mkinstalldirs) $(DESTDIR)$(includedir)
|
||||||
@ -306,7 +344,7 @@ check-am: all-am
|
|||||||
check: check-am
|
check: check-am
|
||||||
installcheck-am:
|
installcheck-am:
|
||||||
installcheck: installcheck-am
|
installcheck: installcheck-am
|
||||||
install-exec-am: install-libLTLIBRARIES
|
install-exec-am: install-libLTLIBRARIES install-binPROGRAMS
|
||||||
install-exec: install-exec-am
|
install-exec: install-exec-am
|
||||||
|
|
||||||
install-data-am: install-includeHEADERS
|
install-data-am: install-includeHEADERS
|
||||||
@ -315,14 +353,16 @@ install-data: install-data-am
|
|||||||
install-am: all-am
|
install-am: all-am
|
||||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||||
install: install-am
|
install: install-am
|
||||||
uninstall-am: uninstall-libLTLIBRARIES uninstall-includeHEADERS
|
uninstall-am: uninstall-libLTLIBRARIES uninstall-binPROGRAMS \
|
||||||
|
uninstall-includeHEADERS
|
||||||
uninstall: uninstall-am
|
uninstall: uninstall-am
|
||||||
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
|
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS)
|
||||||
all-redirect: all-am
|
all-redirect: all-am
|
||||||
install-strip:
|
install-strip:
|
||||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||||
installdirs:
|
installdirs:
|
||||||
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
|
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) \
|
||||||
|
$(DESTDIR)$(includedir)
|
||||||
|
|
||||||
|
|
||||||
mostlyclean-generic:
|
mostlyclean-generic:
|
||||||
@ -335,27 +375,29 @@ distclean-generic:
|
|||||||
|
|
||||||
maintainer-clean-generic:
|
maintainer-clean-generic:
|
||||||
mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \
|
mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \
|
||||||
mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
|
mostlyclean-libtool mostlyclean-binPROGRAMS \
|
||||||
mostlyclean-generic
|
mostlyclean-tags mostlyclean-depend mostlyclean-generic
|
||||||
|
|
||||||
mostlyclean: mostlyclean-am
|
mostlyclean: mostlyclean-am
|
||||||
|
|
||||||
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \
|
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool \
|
||||||
clean-depend clean-generic mostlyclean-am
|
clean-binPROGRAMS clean-tags clean-depend clean-generic \
|
||||||
|
mostlyclean-am
|
||||||
|
|
||||||
clean: clean-am
|
clean: clean-am
|
||||||
|
|
||||||
distclean-am: distclean-libLTLIBRARIES distclean-compile \
|
distclean-am: distclean-libLTLIBRARIES distclean-compile \
|
||||||
distclean-libtool distclean-tags distclean-depend \
|
distclean-libtool distclean-binPROGRAMS distclean-tags \
|
||||||
distclean-generic clean-am
|
distclean-depend distclean-generic clean-am
|
||||||
-rm -f libtool
|
-rm -f libtool
|
||||||
|
|
||||||
distclean: distclean-am
|
distclean: distclean-am
|
||||||
|
|
||||||
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
|
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
|
||||||
maintainer-clean-compile maintainer-clean-libtool \
|
maintainer-clean-compile maintainer-clean-libtool \
|
||||||
maintainer-clean-tags maintainer-clean-depend \
|
maintainer-clean-binPROGRAMS maintainer-clean-tags \
|
||||||
maintainer-clean-generic distclean-am
|
maintainer-clean-depend maintainer-clean-generic \
|
||||||
|
distclean-am
|
||||||
@echo "This command is intended for maintainers to use;"
|
@echo "This command is intended for maintainers to use;"
|
||||||
@echo "it deletes files that may require special tools to rebuild."
|
@echo "it deletes files that may require special tools to rebuild."
|
||||||
|
|
||||||
@ -366,11 +408,13 @@ clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
|
|||||||
uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
|
uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
|
||||||
distclean-compile clean-compile maintainer-clean-compile \
|
distclean-compile clean-compile maintainer-clean-compile \
|
||||||
mostlyclean-libtool distclean-libtool clean-libtool \
|
mostlyclean-libtool distclean-libtool clean-libtool \
|
||||||
maintainer-clean-libtool uninstall-includeHEADERS \
|
maintainer-clean-libtool mostlyclean-binPROGRAMS distclean-binPROGRAMS \
|
||||||
install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \
|
clean-binPROGRAMS maintainer-clean-binPROGRAMS uninstall-binPROGRAMS \
|
||||||
maintainer-clean-tags distdir mostlyclean-depend distclean-depend \
|
install-binPROGRAMS uninstall-includeHEADERS install-includeHEADERS \
|
||||||
clean-depend maintainer-clean-depend info-am info dvi-am dvi check \
|
tags mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
|
||||||
check-am installcheck-am installcheck install-exec-am install-exec \
|
distdir mostlyclean-depend distclean-depend clean-depend \
|
||||||
|
maintainer-clean-depend info-am info dvi-am dvi check check-am \
|
||||||
|
installcheck-am installcheck install-exec-am install-exec \
|
||||||
install-data-am install-data install-am install uninstall-am uninstall \
|
install-data-am install-data install-am install uninstall-am uninstall \
|
||||||
all-redirect all-am all installdirs mostlyclean-generic \
|
all-redirect all-am all installdirs mostlyclean-generic \
|
||||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2004, Wolfgang Hottgenroth
|
Copyright (C) 2004,2005 Wolfgang Hottgenroth
|
||||||
|
|
||||||
This file is part of smmapdfw.
|
This file is part of smmapdfw.
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ typedef struct mydata_s mydata_t;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
htcache_t *cache_init(const char *file, int expiry) {
|
htcache_t *htcache_init(const char *file, int expiry) {
|
||||||
#if ENABLE_CACHE == 1
|
#if ENABLE_CACHE == 1
|
||||||
htcache_t *handle = (htcache_t*) htmalloc(sizeof(htcache_t));
|
htcache_t *handle = (htcache_t*) htmalloc(sizeof(htcache_t));
|
||||||
handle->mutex = (pthread_mutex_t*) htmalloc(sizeof(pthread_mutex_t));
|
handle->mutex = (pthread_mutex_t*) htmalloc(sizeof(pthread_mutex_t));
|
||||||
@ -67,7 +67,7 @@ htcache_t *cache_init(const char *file, int expiry) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cache_destroy(htcache_t *handle) {
|
void htcache_destroy(htcache_t *handle) {
|
||||||
#if ENABLE_CACHE == 1
|
#if ENABLE_CACHE == 1
|
||||||
pthread_mutex_destroy(handle->mutex);
|
pthread_mutex_destroy(handle->mutex);
|
||||||
free(handle->mutex);
|
free(handle->mutex);
|
||||||
@ -75,7 +75,7 @@ void cache_destroy(htcache_t *handle) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cache_insert(htcache_t *handle, const char *key, const void *value, int value_size) {
|
void htcache_insert(htcache_t *handle, const char *key, const char *value, int value_size) {
|
||||||
#if ENABLE_CACHE == 1
|
#if ENABLE_CACHE == 1
|
||||||
DBM *cache;
|
DBM *cache;
|
||||||
datum data, dkey;
|
datum data, dkey;
|
||||||
@ -111,7 +111,7 @@ void cache_insert(htcache_t *handle, const char *key, const void *value, int val
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *cache_lookup(htcache_t *handle, const char* key) {
|
int htcache_lookup(htcache_t *handle, const char* key, char** value, int* value_size2) {
|
||||||
#if ENABLE_CACHE == 1
|
#if ENABLE_CACHE == 1
|
||||||
DBM *cache;
|
DBM *cache;
|
||||||
datum data, dkey;
|
datum data, dkey;
|
||||||
@ -131,13 +131,16 @@ void *cache_lookup(htcache_t *handle, const char* key) {
|
|||||||
dbm_close(cache);
|
dbm_close(cache);
|
||||||
} else {
|
} else {
|
||||||
mydata = (mydata_t *) data.dptr;
|
mydata = (mydata_t *) data.dptr;
|
||||||
syslog(LOG_DEBUG, "cache_lookup: found: %s -> %s (size %d)",
|
syslog(LOG_DEBUG, "cache_lookup: found: %s %d %d %s (size %d)",
|
||||||
key, data.dptr, data.dsize);
|
key, mydata->timestamp, mydata->value_size, mydata->value, data.dsize);
|
||||||
if ((mydata->timestamp + handle->expiry) > time(NULL)) {
|
if ((mydata->timestamp + handle->expiry) > time(NULL)) {
|
||||||
syslog(LOG_DEBUG, "cache_lookup: not yet expired");
|
syslog(LOG_DEBUG, "cache_lookup: not yet expired");
|
||||||
value_size = mydata->value_size;
|
value_size = mydata->value_size;
|
||||||
output = (char*) htmalloc(value_size+5);
|
output = (char*) htmalloc(value_size+5);
|
||||||
memcpy(output, mydata->value, value_size);
|
memcpy(output, mydata->value, value_size);
|
||||||
|
|
||||||
|
*value_size2 = value_size;
|
||||||
|
*value = output;
|
||||||
|
|
||||||
/* Berkeley DB frees on its own! */
|
/* Berkeley DB frees on its own! */
|
||||||
/* free(data.dptr); */
|
/* free(data.dptr); */
|
||||||
@ -157,6 +160,7 @@ void *cache_lookup(htcache_t *handle, const char* key) {
|
|||||||
syslog(LOG_DEBUG, "cache_insert: record deleted");
|
syslog(LOG_DEBUG, "cache_insert: record deleted");
|
||||||
}
|
}
|
||||||
dbm_close(cache);
|
dbm_close(cache);
|
||||||
|
res = -2;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(handle->mutex);
|
pthread_mutex_unlock(handle->mutex);
|
||||||
}
|
}
|
||||||
@ -171,4 +175,3 @@ void *cache_lookup(htcache_t *handle, const char* key) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@ typedef struct htcache_s {
|
|||||||
pthread_mutex_t *mutex;
|
pthread_mutex_t *mutex;
|
||||||
} htcache_t;
|
} htcache_t;
|
||||||
|
|
||||||
htcache_t *cache_init(const char *file, int expiry);
|
htcache_t *htcache_init(const char *file, int expiry);
|
||||||
void cache_destroy(htcache_t *handle);
|
void htcache_destroy(htcache_t *handle);
|
||||||
void cache_insert(htcache_t *handle, const char *key, const void *value, int value_size);
|
void htcache_insert(htcache_t *handle, const char *key, const char *value, int value_size);
|
||||||
void *cache_lookup(htcache_t *handle, const char *key);
|
int htcache_lookup(htcache_t *handle, const char *key, char** value, int* value_size2);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _HTCACHE_H_ */
|
#endif /* _HTCACHE_H_ */
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// #define CACHE_SEPARATED 1
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
@ -35,10 +37,15 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef CACHE_SEPARATED
|
||||||
#if ENABLE_CACHE == 1
|
#if ENABLE_CACHE == 1
|
||||||
#define DB_DBM_HSEARCH 1
|
#define DB_DBM_HSEARCH 1
|
||||||
#include <db.h>
|
#include <db.h>
|
||||||
#endif
|
#endif /* ENABLE_CACHE */
|
||||||
|
#else
|
||||||
|
#include "htcache.h"
|
||||||
|
#endif /* CACHE_SEPARATED */
|
||||||
|
|
||||||
#include "containers_public.h"
|
#include "containers_public.h"
|
||||||
#include "smmapd.h"
|
#include "smmapd.h"
|
||||||
@ -59,10 +66,16 @@ struct verify_container_handle_s {
|
|||||||
cfgl_t *cfg;
|
cfgl_t *cfg;
|
||||||
int timeout_result;
|
int timeout_result;
|
||||||
int timeout_dialog;
|
int timeout_dialog;
|
||||||
|
|
||||||
|
#ifndef CACHE_SEPARATED
|
||||||
int cache_enabled;
|
int cache_enabled;
|
||||||
int cache_expiry;
|
int cache_expiry;
|
||||||
pthread_mutex_t *cache_mutex;
|
pthread_mutex_t *cache_mutex;
|
||||||
char *cache_file;
|
char *cache_file;
|
||||||
|
#else
|
||||||
|
htcache_t *cache;
|
||||||
|
#endif /* CACHE_SEPARATED */
|
||||||
|
|
||||||
char *sender_address;
|
char *sender_address;
|
||||||
char *helo_arg;
|
char *helo_arg;
|
||||||
int smtp_port;
|
int smtp_port;
|
||||||
@ -126,7 +139,9 @@ typedef struct worker_thread_s worker_thread_t;
|
|||||||
|
|
||||||
struct mydata_s {
|
struct mydata_s {
|
||||||
int result;
|
int result;
|
||||||
|
#ifndef CACHE_SEPARATED
|
||||||
time_t timestamp;
|
time_t timestamp;
|
||||||
|
#endif /* CACHE_SEPARATED */
|
||||||
char output[1];
|
char output[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -160,6 +175,8 @@ class_descriptor_t verifier = {
|
|||||||
/* container handle for each class in the application. */
|
/* container handle for each class in the application. */
|
||||||
int verify_init(cfgl_t *cfg, void **handle) {
|
int verify_init(cfgl_t *cfg, void **handle) {
|
||||||
verify_container_handle_t *vch;
|
verify_container_handle_t *vch;
|
||||||
|
int cache_enabled, cache_expiry;
|
||||||
|
char *cache_file;
|
||||||
|
|
||||||
vch = (verify_container_handle_t*) htmalloc(sizeof(verify_container_handle_t));
|
vch = (verify_container_handle_t*) htmalloc(sizeof(verify_container_handle_t));
|
||||||
vch->cfg = cfg;
|
vch->cfg = cfg;
|
||||||
@ -170,6 +187,8 @@ int verify_init(cfgl_t *cfg, void **handle) {
|
|||||||
vch->helo_arg = findcfglx(vch->cfg, "helo_arg", "local");
|
vch->helo_arg = findcfglx(vch->cfg, "helo_arg", "local");
|
||||||
vch->smtp_port = atoi(findcfglx(vch->cfg, "smtp_port", "25"));
|
vch->smtp_port = atoi(findcfglx(vch->cfg, "smtp_port", "25"));
|
||||||
vch->max_checker_threads = atoi(findcfglx(vch->cfg, "max_checker_threads", "25"));
|
vch->max_checker_threads = atoi(findcfglx(vch->cfg, "max_checker_threads", "25"));
|
||||||
|
|
||||||
|
#ifndef CACHE_SEPARATED
|
||||||
vch->cache_enabled = atoi(findcfglx(vch->cfg, "cache_enabled", "1"));
|
vch->cache_enabled = atoi(findcfglx(vch->cfg, "cache_enabled", "1"));
|
||||||
vch->cache_expiry = atoi(findcfglx(vch->cfg, "cache_expiry", "86400"));
|
vch->cache_expiry = atoi(findcfglx(vch->cfg, "cache_expiry", "86400"));
|
||||||
vch->cache_file = findcfglx(vch->cfg, "cache_file", "verifier_cache");
|
vch->cache_file = findcfglx(vch->cfg, "cache_file", "verifier_cache");
|
||||||
@ -181,7 +200,17 @@ int verify_init(cfgl_t *cfg, void **handle) {
|
|||||||
} else {
|
} else {
|
||||||
vch->cache_mutex = NULL;
|
vch->cache_mutex = NULL;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
cache_enabled = atoi(findcfglx(vch->cfg, "cache_enabled", "1"));
|
||||||
|
cache_expiry = atoi(findcfglx(vch->cfg, "cache_expiry", "86400"));
|
||||||
|
cache_file = findcfglx(vch->cfg, "cache_file", "verifier_cache");
|
||||||
|
|
||||||
|
if (1 == cache_enabled) {
|
||||||
|
vch->cache = cache_init(cache_file, cache_expiry);
|
||||||
|
} else {
|
||||||
|
vch->cache = NULL;
|
||||||
|
}
|
||||||
|
#endif /* CACHE_SEPARATED */
|
||||||
|
|
||||||
*handle = vch;
|
*handle = vch;
|
||||||
return 0;
|
return 0;
|
||||||
@ -192,10 +221,17 @@ int verify_init(cfgl_t *cfg, void **handle) {
|
|||||||
int verify_destroy(void *handle) {
|
int verify_destroy(void *handle) {
|
||||||
verify_container_handle_t *vch = (verify_container_handle_t*)handle;
|
verify_container_handle_t *vch = (verify_container_handle_t*)handle;
|
||||||
|
|
||||||
|
#ifndef CACHE_SEPARATED
|
||||||
if (1 == vch->cache_enabled) {
|
if (1 == vch->cache_enabled) {
|
||||||
pthread_mutex_destroy(vch->cache_mutex);
|
pthread_mutex_destroy(vch->cache_mutex);
|
||||||
free(vch->cache_mutex);
|
free(vch->cache_mutex);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (NULL != vch->cache) {
|
||||||
|
cache_destroy(vch->cache);
|
||||||
|
}
|
||||||
|
#endif /* CACHE_SEPARATED */
|
||||||
|
|
||||||
|
|
||||||
free(vch);
|
free(vch);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user