From 8090a550770dd7da5d1ef7c7ff2b301902694629 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 5 Dec 2011 12:27:19 +0100 Subject: [PATCH] sru_z3950: Only call package.log_reset if log also enabled This is to ensure the log is not reset by this filter unless also enabled by it. --- src/filter_sru_to_z3950.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/filter_sru_to_z3950.cpp b/src/filter_sru_to_z3950.cpp index 8c18dab..ae0c3f5 100644 --- a/src/filter_sru_to_z3950.cpp +++ b/src/filter_sru_to_z3950.cpp @@ -211,6 +211,7 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) return; } + bool enable_package_log = false; std::string zurl; Z_SRW_extra_arg *arg; @@ -230,7 +231,10 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) else if (!strcmp(arg->name, "x-log-enable")) { if (*arg->value == '1') + { + enable_package_log = true; package.log_enable(); + } } assert(sru_pdu_req); @@ -293,20 +297,23 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) YAZ_SRW_UNSUPP_OPERATION, "unknown"); } - - std::string l; - package.log_reset(l); - if (l.length()) + if (enable_package_log) { - WRBUF w = wrbuf_alloc(); - - wrbuf_puts(w, "\n"); - wrbuf_xmlputs(w, l.c_str()); - wrbuf_puts(w, ""); - - sru_pdu_res->extraResponseData_len = wrbuf_len(w); - sru_pdu_res->extraResponseData_buf = odr_strdup(odr_en, wrbuf_cstr(w)); - wrbuf_destroy(w); + std::string l; + package.log_reset(l); + if (l.length()) + { + WRBUF w = wrbuf_alloc(); + + wrbuf_puts(w, "\n"); + wrbuf_xmlputs(w, l.c_str()); + wrbuf_puts(w, ""); + + sru_pdu_res->extraResponseData_len = wrbuf_len(w); + sru_pdu_res->extraResponseData_buf = + odr_strdup(odr_en, wrbuf_cstr(w)); + wrbuf_destroy(w); + } } // build and send SRU response -- 1.7.10.4