X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-pdu-assoc-thread.cpp;h=fd4373a3c0b081cecc273000cbdeddeb5adee14c;hb=5e3f7e1a720a08d30c407049c94c6ca825a5ed27;hp=01078d57823cf632b87bf6b1f9194a391215c511;hpb=5238ea544d4a2b414592f1d503f5ed83f305b21b;p=yazpp-moved-to-github.git diff --git a/src/yaz-pdu-assoc-thread.cpp b/src/yaz-pdu-assoc-thread.cpp index 01078d5..fd4373a 100644 --- a/src/yaz-pdu-assoc-thread.cpp +++ b/src/yaz-pdu-assoc-thread.cpp @@ -1,21 +1,28 @@ /* - * Copyright (c) 1998-2001, Index Data. + * Copyright (c) 1998-2004, 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.9 2005-01-14 10:13:50 adam Exp $ */ #ifdef WIN32 +#define USE_THREADS 1 +#endif + +#if YAZ_POSIX_THREADS +#define USE_THREADS 1 +#endif + +#if USE_THREADS + +#if HAVE_UNISTD_H +#include +#endif + +#ifdef WIN32 #include #else #include -#include #endif @@ -23,10 +30,8 @@ #include #include -#include -#include - - +#include +#include Yaz_PDU_AssocThread::Yaz_PDU_AssocThread( IYazSocketObservable *socketObservable) @@ -44,10 +49,10 @@ events(void *p) { Yaz_SocketManager *s = (Yaz_SocketManager *) p; - logf (LOG_LOG, "thread started"); + yaz_log (YLOG_LOG, "thread started"); while (s->processEvent() > 0) ; - logf (LOG_LOG, "thread finished"); + yaz_log (YLOG_LOG, "thread finished"); #ifdef WIN32 #else return 0; @@ -58,7 +63,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)); @@ -67,7 +76,7 @@ void Yaz_PDU_AssocThread::childNotify(COMSTACK cs) t_id = _beginthread (events, 0, socket_observable); if (t_id == -1) { - yaz_log (LOG_FATAL|LOG_ERRNO, "_beginthread failed"); + yaz_log (YLOG_FATAL|YLOG_ERRNO, "_beginthread failed"); exit (1); } #else @@ -75,8 +84,9 @@ void Yaz_PDU_AssocThread::childNotify(COMSTACK cs) int id = pthread_create (&tid, 0, events, socket_observable); if (id) - yaz_log (LOG_ERRNO|LOG_FATAL, "pthread_create returned id=%d", id); + yaz_log (YLOG_ERRNO|YLOG_FATAL, "pthread_create returned id=%d", id); else pthread_detach (tid); #endif } +#endif