[PATCH] geoip_check_cache option
ondrej.novy at firma.seznam.cz
ondrej.novy at firma.seznam.cz
Mon Jul 20 16:12:31 UTC 2015
# HG changeset patch
# User Ondrej Novy <ondrej.novy at firma.seznam.cz>
# Date 1435152464 -7200
# Wed Jun 24 15:27:44 2015 +0200
# Node ID 4c77bf00ab889d1b120892ec8b707f4717941791
# Parent 24488e6db782e24b9a30ba31f0b719204e582918
geoip_check_cache option.
Allow to enable GEOIP_CHECK_CACHE option in GeoIP lib. When enabled
this lib checks for changes of DB every second and reload it if needed.
diff -r 24488e6db782 -r 4c77bf00ab88 contrib/vim/syntax/nginx.vim
--- a/contrib/vim/syntax/nginx.vim Tue Jun 23 20:17:48 2015 +0300
+++ b/contrib/vim/syntax/nginx.vim Wed Jun 24 15:27:44 2015 +0200
@@ -167,6 +167,7 @@
syn keyword ngxDirective geoip_org
syn keyword ngxDirective geoip_proxy
syn keyword ngxDirective geoip_proxy_recursive
+syn keyword ngxDirective geoip_check_cache
syn keyword ngxDirective google_perftools_profiles
syn keyword ngxDirective gunzip
syn keyword ngxDirective gunzip_buffers
diff -r 24488e6db782 -r 4c77bf00ab88 src/http/modules/ngx_http_geoip_module.c
--- a/src/http/modules/ngx_http_geoip_module.c Tue Jun 23 20:17:48 2015 +0300
+++ b/src/http/modules/ngx_http_geoip_module.c Wed Jun 24 15:27:44 2015 +0200
@@ -24,6 +24,7 @@
GeoIP *city;
ngx_array_t *proxies; /* array of ngx_cidr_t */
ngx_flag_t proxy_recursive;
+ ngx_flag_t check_cache;
#if (NGX_HAVE_GEOIP_V6)
unsigned country_v6:1;
unsigned org_v6:1;
@@ -131,6 +132,13 @@
offsetof(ngx_http_geoip_conf_t, proxy_recursive),
NULL },
+ { ngx_string("geoip_check_cache"),
+ NGX_HTTP_MAIN_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_MAIN_CONF_OFFSET,
+ offsetof(ngx_http_geoip_conf_t, check_cache),
+ NULL },
+
ngx_null_command
};
@@ -649,6 +657,7 @@
}
conf->proxy_recursive = NGX_CONF_UNSET;
+ conf->check_cache = NGX_CONF_UNSET;
cln = ngx_pool_cleanup_add(cf->pool, 0);
if (cln == NULL) {
@@ -668,6 +677,7 @@
ngx_http_geoip_conf_t *gcf = conf;
ngx_conf_init_value(gcf->proxy_recursive, 0);
+ ngx_conf_init_value(gcf->check_cache, 0);
return NGX_CONF_OK;
}
@@ -686,7 +696,8 @@
value = cf->args->elts;
- gcf->country = GeoIP_open((char *) value[1].data, GEOIP_MEMORY_CACHE);
+ gcf->country = GeoIP_open((char *) value[1].data, GEOIP_MEMORY_CACHE |
+ gcf->check_cache ? GEOIP_CHECK_CACHE : 0);
if (gcf->country == NULL) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
@@ -741,7 +752,8 @@
value = cf->args->elts;
- gcf->org = GeoIP_open((char *) value[1].data, GEOIP_MEMORY_CACHE);
+ gcf->org = GeoIP_open((char *) value[1].data, GEOIP_MEMORY_CACHE |
+ gcf->check_cache ? GEOIP_CHECK_CACHE : 0);
if (gcf->org == NULL) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
@@ -802,7 +814,8 @@
value = cf->args->elts;
- gcf->city = GeoIP_open((char *) value[1].data, GEOIP_MEMORY_CACHE);
+ gcf->city = GeoIP_open((char *) value[1].data, GEOIP_MEMORY_CACHE |
+ gcf->check_cache ? GEOIP_CHECK_CACHE : 0);
if (gcf->city == NULL) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
More information about the nginx-devel
mailing list