static void ngx_http_groonga_close_database_callback(ngx_http_groonga_loc_conf_t *location_conf, void *user_data) { ngx_http_groonga_database_callback_data_t *data = user_data; grn_ctx *context; context = &(location_conf->context); ngx_http_groonga_context_init_logger(context, location_conf, data->pool, data->log); ngx_http_groonga_context_init_query_logger(context, location_conf, data->pool, data->log); 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); }
static ngx_int_t ngx_http_groonga_context_init(grn_ctx *context, ngx_http_groonga_loc_conf_t *location_conf, ngx_pool_t *pool, ngx_log_t *log) { ngx_int_t status; grn_ctx_init(context, GRN_NO_FLAGS); status = ngx_http_groonga_context_init_logger(context, location_conf, pool, log); if (status == NGX_ERROR) { grn_ctx_fin(context); return status; } status = ngx_http_groonga_context_init_query_logger(context, location_conf, pool, log); if (status == NGX_ERROR) { grn_ctx_fin(context); return status; } if (location_conf->cache) { grn_cache_current_set(context, location_conf->cache); } return status; }
static ngx_int_t ngx_http_groonga_context_init(ngx_http_groonga_loc_conf_t *location_conf, ngx_pool_t *pool, ngx_log_t *log) { ngx_int_t status; if (location_conf == ngx_http_groonga_current_location_conf) { return NGX_OK; } status = ngx_http_groonga_context_init_logger(location_conf, pool, log); if (status == NGX_ERROR) { return status; } status = ngx_http_groonga_context_init_query_logger(location_conf, pool, log); if (status == NGX_ERROR) { return status; } grn_ctx_use(context, location_conf->database); grn_cache_current_set(context, location_conf->cache); /* TODO: It doesn't work yet. We need to implement request timeout * handler. */ if (location_conf->default_request_timeout_msec == NGX_CONF_UNSET_MSEC) { grn_set_default_request_timeout(0.0); } else { double timeout; timeout = location_conf->default_request_timeout_msec / 1000.0; grn_set_default_request_timeout(timeout); } ngx_http_groonga_current_location_conf = location_conf; return status; }