Log request number. More configurable keepalive with pdu/bw limits.
[yazpp-moved-to-github.git] / src / yaz-z-assoc.cpp
index 052c059..91b47ce 100644 (file)
@@ -2,14 +2,14 @@
  * Copyright (c) 1998-2001, Index Data.
  * See the file LICENSE for details.
  * 
- * $Id: yaz-z-assoc.cpp,v 1.22 2001-11-04 22:36:21 adam Exp $
+ * $Id: yaz-z-assoc.cpp,v 1.26 2003-10-01 13:13:51 adam Exp $
  */
 
 #include <assert.h>
 #include <signal.h>
 
 #include <yaz/log.h>
-#include <yaz++/yaz-z-assoc.h>
+#include <yaz++/z-assoc.h>
 #include <yaz/otherinfo.h>
 
 int Yaz_Z_Assoc::yaz_init_func()
@@ -78,7 +78,7 @@ void Yaz_Z_Assoc::recv_PDU(const char *buf, int len)
     Z_APDU *apdu = decode_Z_PDU (buf, len);
     if (apdu)
     {
-       recv_Z_PDU (apdu);
+       recv_Z_PDU (apdu, len);
     }
     else
     {
@@ -169,12 +169,16 @@ void Yaz_Z_Assoc::transfer_referenceId(Z_APDU *from, Z_APDU *to)
        *id_to = 0;
 }
 
-int Yaz_Z_Assoc::send_Z_PDU(Z_APDU *apdu)
+int Yaz_Z_Assoc::send_Z_PDU(Z_APDU *apdu, int *plen)
 {
     char *buf;
     int len;
     if (encode_Z_PDU(apdu, &buf, &len) > 0)
+    {
+       if (plen)
+           *plen = len;
        return m_PDU_Observable->send_PDU(buf, len);
+    }
     return -1;
 }
 
@@ -197,7 +201,10 @@ Z_APDU *Yaz_Z_Assoc::decode_Z_PDU(const char *buf, int len)
     else
     {
        if (m_APDU_file)
+        {
            z_APDU(m_odr_print, &apdu, 0, "decode");
+           fflush(m_APDU_file);
+       }
         return apdu;
     }
 }
@@ -205,9 +212,14 @@ Z_APDU *Yaz_Z_Assoc::decode_Z_PDU(const char *buf, int len)
 int Yaz_Z_Assoc::encode_Z_PDU(Z_APDU *apdu, char **buf, int *len)
 {
     if (m_APDU_file)
+    {
        z_APDU(m_odr_print, &apdu, 0, "encode");
+       fflush(m_APDU_file);
+    }
     if (!z_APDU(m_odr_out, &apdu, 0, 0))
     {
+       if (m_APDU_file)
+           fprintf (m_APDU_file, "PDU encode failed (above)");
        yaz_log (LOG_LOG, "yaz_Z_Assoc::encode_Z_PDU failed");
         return -1;
     }