2 * Copyright (c) 1998-2004, Index Data.
3 * See the file LICENSE for details.
5 * $Id: yaz-pdu-assoc-thread.cpp,v 1.8 2004-12-13 20:50:54 adam Exp $
27 #include <yaz/tcpip.h>
29 #include <yaz++/pdu-assoc.h>
30 #include <yaz++/socket-manager.h>
32 Yaz_PDU_AssocThread::Yaz_PDU_AssocThread(
33 IYazSocketObservable *socketObservable)
34 : Yaz_PDU_Assoc(socketObservable)
46 Yaz_SocketManager *s = (Yaz_SocketManager *) p;
48 yaz_log (YLOG_LOG, "thread started");
49 while (s->processEvent() > 0)
51 yaz_log (YLOG_LOG, "thread finished");
58 void Yaz_PDU_AssocThread::childNotify(COMSTACK cs)
60 Yaz_SocketManager *socket_observable = new Yaz_SocketManager;
61 Yaz_PDU_Assoc *new_observable = new Yaz_PDU_Assoc (socket_observable, cs);
63 new_observable->m_next = m_children;
64 m_children = new_observable;
65 new_observable->m_parent = this;
67 /// Clone PDU Observer
68 new_observable->m_PDU_Observer =
69 m_PDU_Observer->sessionNotify(new_observable, cs_fileno(cs));
72 t_id = _beginthread (events, 0, socket_observable);
75 yaz_log (YLOG_FATAL|YLOG_ERRNO, "_beginthread failed");
81 int id = pthread_create (&tid, 0, events, socket_observable);
83 yaz_log (YLOG_ERRNO|YLOG_FATAL, "pthread_create returned id=%d", id);