Log request number. More configurable keepalive with pdu/bw limits.
[yazpp-moved-to-github.git] / src / yaz-pdu-assoc-thread.cpp
index 01078d5..ea63b6a 100644 (file)
@@ -2,31 +2,32 @@
  * Copyright (c) 1998-2001, Index Data.
  * See the file LICENSE for details.
  * 
- * $Log: yaz-pdu-assoc-thread.cpp,v $
- * Revision 1.2  2001-03-27 14:47:45  adam
- * New server facility scheme.
- *
- * Revision 1.1  2001/03/26 14:43:49  adam
- * New threaded PDU association.
- *
+ * $Id: yaz-pdu-assoc-thread.cpp,v 1.6 2002-10-09 12:50:26 adam Exp $
  */
 
 #ifdef WIN32
+#define USE_THREADS 1
+#endif
+
+#if YAZ_POSIX_THREADS
+#define USE_THREADS 1
+#endif
+
+#if USE_THREADS
+
+#ifdef WIN32
 #include <process.h>
 #else
 #include <pthread.h>
 #include <unistd.h>
 #endif
 
-
 #include <errno.h>
 #include <yaz/log.h>
 #include <yaz/tcpip.h>
 
-#include <yaz++/yaz-pdu-assoc.h>
-#include <yaz++/yaz-socket-manager.h>
-
-
+#include <yaz++/pdu-assoc.h>
+#include <yaz++/socket-manager.h>
 
 Yaz_PDU_AssocThread::Yaz_PDU_AssocThread(
     IYazSocketObservable *socketObservable)
@@ -44,10 +45,10 @@ events(void *p)
 {
     Yaz_SocketManager *s = (Yaz_SocketManager *) p;
     
-    logf (LOG_LOG, "thread started");
+    yaz_log (LOG_LOG, "thread started");
     while (s->processEvent() > 0)
        ;
-    logf (LOG_LOG, "thread finished");
+    yaz_log (LOG_LOG, "thread finished");
 #ifdef WIN32
 #else
     return 0;
@@ -58,7 +59,11 @@ void Yaz_PDU_AssocThread::childNotify(COMSTACK cs)
 {
     Yaz_SocketManager *socket_observable = new Yaz_SocketManager;
     Yaz_PDU_Assoc *new_observable = new Yaz_PDU_Assoc (socket_observable, cs);
-    
+
+    new_observable->m_next = m_children;
+    m_children = new_observable;
+    new_observable->m_parent = this;
+
     /// Clone PDU Observer
     new_observable->m_PDU_Observer =
        m_PDU_Observer->sessionNotify(new_observable, cs_fileno(cs));
@@ -80,3 +85,4 @@ void Yaz_PDU_AssocThread::childNotify(COMSTACK cs)
        pthread_detach (tid);
 #endif
 }
+#endif