Fix Present request out of range for proxy
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 24 Jan 2003 20:10:57 +0000 (20:10 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 24 Jan 2003 20:10:57 +0000 (20:10 +0000)
ChangeLog
src/yaz-proxy.cpp

index ce23ba4..e0de222 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+Bug fix: in some cases the Proxy could issue a Present Request
+which was out of range (code 13).
+
 New autoconf m4 macro in yazpp.m4.
 
 Fix creation of src/yaz++-config so that it works if srcdir != objdir.
index f61547a..5f364f2 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1998-2001, Index Data.
  * See the file LICENSE for details.
  * 
- * $Id: yaz-proxy.cpp,v 1.37 2002-10-23 10:15:18 adam Exp $
+ * $Id: yaz-proxy.cpp,v 1.38 2003-01-24 20:10:57 adam Exp $
  */
 
 #include <assert.h>
@@ -265,8 +265,8 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu)
 {
     if (apdu->which != Z_APDU_searchRequest)
        return apdu;
-    if (*m_parent->m_optimize != '1')
-        return apdu;
+    if (*m_parent->m_optimize == '0')
+        return apdu;      // don't optimize result sets..
     Z_SearchRequest *sr = apdu->u.searchRequest;
     Yaz_Z_Query *this_query = new Yaz_Z_Query;
     Yaz_Z_Databases this_databases;
@@ -293,7 +293,10 @@ Z_APDU *Yaz_Proxy::result_set_optimize(Z_APDU *apdu)
            pr->referenceId = sr->referenceId;
            pr->resultSetId = sr->resultSetName;
            pr->preferredRecordSyntax = sr->preferredRecordSyntax;
-           *pr->numberOfRecordsRequested = *sr->mediumSetPresentNumber;
+            if (*sr->mediumSetPresentNumber < m_client->m_last_resultCount)
+                *pr->numberOfRecordsRequested = *sr->mediumSetPresentNumber;
+            else
+                *pr->numberOfRecordsRequested = m_client->m_last_resultCount;
            if (sr->mediumSetElementSetNames)
            {
                pr->recordComposition = (Z_RecordComposition *)