Skip to content
Snippets Groups Projects
Commit aba71f46 authored by Francesco Giacomini's avatar Francesco Giacomini
Browse files

vomsdata as a global variable

Declare vomsdata globally and initialize it lazily at first use,
reusing the same object for all the Retrieve() calls.
parent a159bd06
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,8 @@ ngx_module_t ngx_http_voms_module = { ...@@ -46,6 +46,8 @@ ngx_module_t ngx_http_voms_module = {
NGX_MODULE_V1_PADDING // NGX_MODULE_V1_PADDING //
}; };
static std::unique_ptr<vomsdata> vomsdata_ptr;
static ngx_int_t get_voms_fqans( // static ngx_int_t get_voms_fqans( //
ngx_http_request_t* r, ngx_http_request_t* r,
ngx_http_variable_value_t* v, ngx_http_variable_value_t* v,
...@@ -139,25 +141,27 @@ static MaybeVomsAc retrieve_voms_ac_from_proxy(ngx_http_request_t* r) ...@@ -139,25 +141,27 @@ static MaybeVomsAc retrieve_voms_ac_from_proxy(ngx_http_request_t* r)
return boost::none; return boost::none;
} }
vomsdata vd; if (!vomsdata_ptr) {
auto ok = vd.Retrieve(client_cert.get(), client_chain, RECURSE_CHAIN); vomsdata_ptr.reset(new vomsdata);
}
auto ok = vomsdata_ptr->Retrieve(client_cert.get(), client_chain, RECURSE_CHAIN);
if (!ok) { if (!ok) {
// vd.error is not interpreted correctly by the logger, which probably uses // vd.error is not interpreted correctly by the logger, which probably uses
// errno // errno
ngx_log_error(NGX_LOG_ERR, ngx_log_error(NGX_LOG_ERR,
r->connection->log, r->connection->log,
vd.error, vomsdata_ptr->error,
"%s", "%s",
vd.ErrorMessage().c_str()); vomsdata_ptr->ErrorMessage().c_str());
return boost::none; return boost::none;
} }
if (vd.data.empty()) { if (vomsdata_ptr->data.empty()) {
ngx_log_error(NGX_LOG_DEBUG, r->connection->log, 0, "no ACs in proxy"); ngx_log_error(NGX_LOG_DEBUG, r->connection->log, 0, "no ACs in proxy");
return boost::none; return boost::none;
} }
return vd.data.front(); return vomsdata_ptr->data.front();
} }
static void clean_voms_ac(void* data) static void clean_voms_ac(void* data)
...@@ -219,7 +223,7 @@ static ngx_int_t get_voms_fqans(ngx_http_request_t* r, ...@@ -219,7 +223,7 @@ static ngx_int_t get_voms_fqans(ngx_http_request_t* r,
return NGX_OK; return NGX_OK;
} }
auto fqans = boost::algorithm::join(ac->fqans, ","); auto fqans = boost::algorithm::join(ac->fqan, ",");
auto data = static_cast<u_char*>(ngx_pnalloc(r->pool, fqans.size())); auto data = static_cast<u_char*>(ngx_pnalloc(r->pool, fqans.size()));
if (!data) { if (!data) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment