Added referenceId handling for server.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 25 Apr 2001 18:59:30 +0000 (18:59 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 25 Apr 2001 18:59:30 +0000 (18:59 +0000)
include/yaz++/yaz-z-assoc.h
src/yaz-proxy.cpp
src/yaz-z-assoc.cpp
src/yaz-z-server-sr.cpp

index 7432379..490a046 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1998-2000, Index Data.
  * See the file LICENSE for details.
  * 
- * $Id: yaz-z-assoc.h,v 1.1 2000-10-11 11:58:16 adam Exp $
+ * $Id: yaz-z-assoc.h,v 1.2 2001-04-25 18:59:30 adam Exp $
  */
 
 #ifndef YAZ_Z_ASSOC_INCLUDED
@@ -74,7 +74,9 @@ class YAZ_EXPORT Yaz_Z_Assoc : public IYaz_PDU_Observer {
        int oidval, int categoryValue,
        const char *str);
 
-    Z_ReferenceId* getRefID(char* str);
+    Z_ReferenceId *getRefID(char* str);
+    Z_ReferenceId **get_referenceIdP(Z_APDU *apdu);
+    void transfer_referenceId(Z_APDU *from, Z_APDU *to);
 
     const char *get_hostname();
 
index 8609021..c463833 100644 (file)
@@ -3,7 +3,10 @@
  * See the file LICENSE for details.
  * 
  * $Log: yaz-proxy.cpp,v $
- * Revision 1.24  2001-04-10 10:48:08  adam
+ * Revision 1.25  2001-04-25 18:59:30  adam
+ * Added referenceId handling for server.
+ *
+ * Revision 1.24  2001/04/10 10:48:08  adam
  * Fixed problem where proxy could cash bad result sets.
  *
  * Revision 1.23  2001/03/26 14:43:49  adam
@@ -463,6 +466,10 @@ void Yaz_Proxy::shutdown()
            abort();
        delete m_client;
     }
+    else if (!m_parent)
+    {
+       abort();
+    }
     delete this;
 }
 
index 94b8638..8782136 100644 (file)
@@ -3,7 +3,10 @@
  * See the file LICENSE for details.
  * 
  * $Log: yaz-z-assoc.cpp,v $
- * Revision 1.19  2001-03-27 14:47:45  adam
+ * Revision 1.20  2001-04-25 18:59:30  adam
+ * Added referenceId handling for server.
+ *
+ * Revision 1.19  2001/03/27 14:47:45  adam
  * New server facility scheme.
  *
  * Revision 1.18  2001/03/26 14:43:49  adam
@@ -167,6 +170,75 @@ Z_APDU *Yaz_Z_Assoc::create_Z_PDU(int type)
     return apdu;
 }
 
+Z_ReferenceId **Yaz_Z_Assoc::get_referenceIdP(Z_APDU *apdu)
+{
+    switch (apdu->which)
+    {
+    case  Z_APDU_initRequest:
+       return &apdu->u.initRequest->referenceId; 
+    case  Z_APDU_initResponse:
+       return &apdu->u.initResponse->referenceId;
+    case  Z_APDU_searchRequest:
+       return &apdu->u.searchRequest->referenceId;
+    case  Z_APDU_searchResponse:
+       return &apdu->u.searchResponse->referenceId;
+    case  Z_APDU_presentRequest:
+       return &apdu->u.presentRequest->referenceId;
+    case  Z_APDU_presentResponse:
+       return &apdu->u.presentResponse->referenceId;
+    case  Z_APDU_deleteResultSetRequest:
+       return &apdu->u.deleteResultSetRequest->referenceId;
+    case  Z_APDU_deleteResultSetResponse:
+       return &apdu->u.deleteResultSetResponse->referenceId;
+    case  Z_APDU_accessControlRequest:
+       return &apdu->u.accessControlRequest->referenceId;
+    case  Z_APDU_accessControlResponse:
+       return &apdu->u.accessControlResponse->referenceId;
+    case  Z_APDU_resourceControlRequest:
+       return &apdu->u.resourceControlRequest->referenceId;
+    case  Z_APDU_resourceControlResponse:
+       return &apdu->u.resourceControlResponse->referenceId;
+    case  Z_APDU_triggerResourceControlRequest:
+       return &apdu->u.triggerResourceControlRequest->referenceId;
+    case  Z_APDU_resourceReportRequest:
+       return &apdu->u.resourceReportRequest->referenceId;
+    case  Z_APDU_resourceReportResponse:
+       return &apdu->u.resourceReportResponse->referenceId;
+    case  Z_APDU_scanRequest:
+       return &apdu->u.scanRequest->referenceId;
+    case  Z_APDU_scanResponse:
+       return &apdu->u.scanResponse->referenceId;
+    case  Z_APDU_sortRequest:
+       return &apdu->u.sortRequest->referenceId;
+    case  Z_APDU_sortResponse:
+       return &apdu->u.sortResponse->referenceId;
+    case  Z_APDU_segmentRequest:
+       return &apdu->u.segmentRequest->referenceId;
+    case  Z_APDU_extendedServicesRequest:
+       return &apdu->u.extendedServicesRequest->referenceId;
+    case  Z_APDU_extendedServicesResponse:
+       return &apdu->u.extendedServicesResponse->referenceId;
+    case  Z_APDU_close:
+       return &apdu->u.close->referenceId;
+    }
+    return 0;
+}
+
+void Yaz_Z_Assoc::transfer_referenceId(Z_APDU *from, Z_APDU *to)
+{
+    Z_ReferenceId **id_from = get_referenceIdP(from);
+    Z_ReferenceId **id_to = get_referenceIdP(to);
+    if (id_from && *id_from && id_to)
+    {
+       *id_to = (Z_ReferenceId*) odr_malloc (m_odr_out, sizeof(**id_to));
+       (*id_to)->size = (*id_to)->len = (*id_from)->len;
+       (*id_to)->buf = (unsigned char*) odr_malloc (m_odr_out, (*id_to)->len);
+       memcpy ((*id_to)->buf, (*id_from)->buf, (*id_to)->len);
+    }
+    else if (id_to)
+       *id_to = 0;
+}
+
 int Yaz_Z_Assoc::send_Z_PDU(Z_APDU *apdu)
 {
     char *buf;
index 4c0b58d..9750e16 100644 (file)
@@ -3,7 +3,10 @@
  * See the file LICENSE for details.
  * 
  * $Log: yaz-z-server-sr.cpp,v $
- * Revision 1.2  2001-04-04 14:02:49  adam
+ * Revision 1.3  2001-04-25 18:59:30  adam
+ * Added referenceId handling for server.
+ *
+ * Revision 1.2  2001/04/04 14:02:49  adam
  * URSULA / Z-ruth service.
  *
  * Revision 1.1  2001/03/27 15:02:14  adam
@@ -227,6 +230,7 @@ int Yaz_Facility_Retrieval::recv(Yaz_Z_Server *s, Z_APDU *apdu_request)
     case Z_APDU_searchRequest:
         yaz_log (LOG_LOG, "got SearchRequest p=%p", this);
        apdu_response = s->create_Z_PDU(Z_APDU_searchResponse);
+       s->transfer_referenceId(apdu_request, apdu_response);
        sr_search (apdu_request->u.searchRequest,
                       apdu_response->u.searchResponse);
        if (!apdu_response->u.searchResponse->records)
@@ -239,6 +243,7 @@ int Yaz_Facility_Retrieval::recv(Yaz_Z_Server *s, Z_APDU *apdu_request)
     case Z_APDU_presentRequest:
         yaz_log (LOG_LOG, "got PresentRequest p=%p", this);
        apdu_response = s->create_Z_PDU(Z_APDU_presentResponse);
+       s->transfer_referenceId(apdu_request, apdu_response);
        sr_present (apdu_request->u.presentRequest,
                    apdu_response->u.presentResponse);
        if (!apdu_response->u.presentResponse->records)