From b0aa31dcb0e69f1e7d0791f4f8df6b1f0529fd7e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 30 Jun 2010 14:23:34 +0200 Subject: [PATCH] session_shared: init fail: close backend. Ensure that backend session is closed if session_shared filter receives init rejected and backend session is not closed already. --- src/filter_session_shared.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/filter_session_shared.cpp b/src/filter_session_shared.cpp index d36fabb..c6615ea 100644 --- a/src/filter_session_shared.cpp +++ b/src/filter_session_shared.cpp @@ -377,13 +377,17 @@ yf::SessionShared::BackendInstancePtr yf::SessionShared::BackendClass::create_ba m_named_result_sets = false; Z_GDU *gdu = init_package.response().get(); - if (!init_package.session().is_closed() - && gdu && gdu->which == Z_GDU_Z3950 - && gdu->u.z3950->which == Z_APDU_initResponse) + if (init_package.session().is_closed()) + { + /* already closed. We don't know why */ + return null; + } + else if (gdu && gdu->which == Z_GDU_Z3950 + && gdu->u.z3950->which == Z_APDU_initResponse + && *gdu->u.z3950->u.initResponse->result) { + /* successful init response */ Z_InitResponse *res = gdu->u.z3950->u.initResponse; - if (!*res->result) - return null; m_init_response = gdu->u.z3950; if (ODR_MASK_GET(res->options, Z_Options_namedResultSets)) { @@ -392,7 +396,10 @@ yf::SessionShared::BackendInstancePtr yf::SessionShared::BackendClass::create_ba } else { - // did not receive an init response or closed + /* not init or init rejected */ + init_package.copy_filter(frontend_package); + init_package.session().close(); + init_package.move(); return null; } bp->m_in_use = true; @@ -610,7 +617,6 @@ restart: BackendClassPtr bc = m_backend_class; { boost::mutex::scoped_lock lock(bc->m_mutex_backend_class); - // look at each backend and see if we have a similar search BackendInstanceList::const_iterator it = bc->m_backend_list.begin(); -- 1.7.10.4