Kouhei Sutou
null+****@clear*****
Tue Sep 24 17:06:54 JST 2013
Kouhei Sutou 2013-09-24 17:06:54 +0900 (Tue, 24 Sep 2013) New Revision: 03e9958cbd9f3dd3fc5b0bcd5c4f77a43c81f3b7 https://github.com/groonga/groonga/commit/03e9958cbd9f3dd3fc5b0bcd5c4f77a43c81f3b7 Message: groonga-httpd: fix cache is shared by diffferent database Cache is used for each database. Modified files: src/httpd/nginx-module/ngx_http_groonga_module.c Modified: src/httpd/nginx-module/ngx_http_groonga_module.c (+20 -0) =================================================================== --- src/httpd/nginx-module/ngx_http_groonga_module.c 2013-09-24 17:06:02 +0900 (6c12940) +++ src/httpd/nginx-module/ngx_http_groonga_module.c 2013-09-24 17:06:54 +0900 (f364bf7) @@ -43,6 +43,7 @@ typedef struct { int config_line; char *name; grn_ctx context; + grn_cache *cache; } ngx_http_groonga_loc_conf_t; typedef struct { @@ -257,6 +258,10 @@ ngx_http_groonga_context_init(grn_ctx *context, grn_ctx_fin(context); } + if (location_conf->cache) { + grn_cache_current_set(context, location_conf->cache); + } + return status; } @@ -935,6 +940,7 @@ ngx_http_groonga_create_loc_conf(ngx_conf_t *cf) conf->query_log_file = NULL; conf->config_file = NULL; conf->config_line = 0; + conf->cache = NULL; return conf; } @@ -1134,6 +1140,15 @@ ngx_http_groonga_open_database_callback(ngx_http_groonga_loc_conf_t *location_co return; } } + + location_conf->cache = grn_cache_open(context); + if (!location_conf->cache) { + ngx_log_error(NGX_LOG_EMERG, data->log, 0, + "failed to open groonga cache: %s", + context->errbuf); + data->rc = NGX_ERROR; + return; + } } static void @@ -1144,9 +1159,14 @@ ngx_http_groonga_close_database_callback(ngx_http_groonga_loc_conf_t *location_c grn_ctx *context; context = &(location_conf->context); + grn_cache_current_set(context, location_conf->cache); grn_obj_close(context, grn_ctx_db(context)); ngx_http_groonga_context_log_error(data->log, context); + + grn_cache_current_set(context, NULL); + grn_cache_close(context, location_conf->cache); + grn_ctx_fin(context); } -------------- next part -------------- HTML����������������������������... Download