Set referenceId for response PDU to avoid unknown IDs for Voyager target
[yazpp-moved-to-github.git] / src / yaz-proxy.cpp
index cd82f0a..0e423d9 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1998-2004, Index Data.
  * See the file LICENSE for details.
  * 
- * $Id: yaz-proxy.cpp,v 1.94 2004-01-30 11:45:26 adam Exp $
+ * $Id: yaz-proxy.cpp,v 1.97 2004-02-02 15:11:41 adam Exp $
  */
 
 #include <assert.h>
@@ -100,9 +100,11 @@ Yaz_Proxy::Yaz_Proxy(IYaz_PDU_Observable *the_PDU_Observable,
     m_config_fname = 0;
     m_request_no = 0;
     m_invalid_session = 0;
+    m_referenceId = 0;
     m_config = 0;
     m_marcxml_flag = 0;
     m_stylesheet_xsp = 0;
+    m_stylesheet_nprl = 0;
     m_s2z_stylesheet = 0;
     m_s2z_database = 0;
     m_schema = 0;
@@ -628,13 +630,12 @@ void Yaz_Proxy::convert_xsl_delay()
     m_stylesheet_offset++;
     if (m_stylesheet_offset == m_stylesheet_nprl->num_records)
     {
+       m_stylesheet_nprl = 0;
        if (m_stylesheet_xsp)
            xsltFreeStylesheet(m_stylesheet_xsp);
        m_stylesheet_xsp = 0;
        timeout(m_client_idletime);
        int r = send_PDU_convert(m_stylesheet_apdu);
-       if (r)
-           return;
     }
     else
        timeout(0);
@@ -978,6 +979,11 @@ int Yaz_Proxy::send_PDU_convert(Z_APDU *apdu)
 int Yaz_Proxy::send_to_client(Z_APDU *apdu)
 {
     int kill_session = 0;
+    Z_ReferenceId **new_id = get_referenceIdP(apdu);
+
+    if (new_id && m_referenceId)
+       *new_id = *m_referenceId;
+    
     if (apdu->which == Z_APDU_searchResponse)
     {
        Z_SearchResponse *sr = apdu->u.searchResponse;
@@ -1917,6 +1923,8 @@ void Yaz_Proxy::handle_incoming_Z_PDU(Z_APDU *apdu)
        m_mem_invalid_session = odr_extract_mem(odr_decode());
        apdu = m_initRequest_apdu;
     }
+    
+    m_referenceId = get_referenceIdP(apdu);
 
     // Determine our client.
     Z_OtherInformation **oi;
@@ -2383,7 +2391,6 @@ int Yaz_Proxy::handle_init_response_for_invalid_session(Z_APDU *apdu)
 void Yaz_ProxyClient::recv_Z_PDU(Z_APDU *apdu, int len)
 {
     m_bytes_recv += len;
-    yaz_log(LOG_LOG, "m_bytes_recv += %d (now %d)", len, m_bytes_recv);
 
     m_pdu_recv++;
     m_waiting = 0;