From: Adam Dickmeiss Date: Wed, 30 Jun 2010 12:26:23 +0000 (+0200) Subject: virt_db: fix uninit error_code. X-Git-Tag: v1.1.7~4 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=403de0130367b13025392c34022bb4e8857862ae;p=metaproxy-moved-to-github.git virt_db: fix uninit error_code. The init_backend, the reference variable error_code, could be unset in some cases. This patch fixes this. It also is more careful not saving a backend to m_backend_list unless init result is OK and connection is not closed. --- diff --git a/src/filter_virt_db.cpp b/src/filter_virt_db.cpp index 10d3f3d..06221d8 100644 --- a/src/filter_virt_db.cpp +++ b/src/filter_virt_db.cpp @@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #include #include @@ -227,21 +228,21 @@ yf::VirtualDB::BackendPtr yf::VirtualDB::Frontend::init_backend( Z_GDU *gdu = init_package.response().get(); // we hope to get an init response - if (gdu && gdu->which == Z_GDU_Z3950 && gdu->u.z3950->which == - Z_APDU_initResponse) + error_code = YAZ_BIB1_DATABASE_UNAVAILABLE; + if (gdu && gdu->which == Z_GDU_Z3950 + && gdu->u.z3950->which == Z_APDU_initResponse + && *gdu->u.z3950->u.initResponse->result) { Z_InitResponse *res = gdu->u.z3950->u.initResponse; if (ODR_MASK_GET(res->options, Z_Options_namedResultSets)) { b->m_named_result_sets = true; } - if (*res->result) + if (*res->result && !init_package.session().is_closed()) { m_backend_list.push_back(b); return b; - } - error_code = YAZ_BIB1_DATABASE_UNAVAILABLE; mp::util::get_init_diagnostics(res, error_code, addinfo); } if (!init_package.session().is_closed())