2 * Copyright (c) 1998-2004, Index Data.
3 * See the file LICENSE for details.
5 * $Id: yaz-pdu-assoc-thread.cpp,v 1.10 2005-06-02 06:40:21 adam Exp $
31 #include <yaz/tcpip.h>
33 #include <yaz++/pdu-assoc.h>
34 #include <yaz++/socket-manager.h>
36 using namespace yazpp_1;
38 Yaz_PDU_AssocThread::Yaz_PDU_AssocThread(
39 IYazSocketObservable *socketObservable)
40 : Yaz_PDU_Assoc(socketObservable)
52 Yaz_SocketManager *s = (Yaz_SocketManager *) p;
54 yaz_log (YLOG_LOG, "thread started");
55 while (s->processEvent() > 0)
57 yaz_log (YLOG_LOG, "thread finished");
64 void Yaz_PDU_AssocThread::childNotify(COMSTACK cs)
66 Yaz_SocketManager *socket_observable = new Yaz_SocketManager;
67 Yaz_PDU_Assoc *new_observable = new Yaz_PDU_Assoc (socket_observable, cs);
69 new_observable->m_next = m_children;
70 m_children = new_observable;
71 new_observable->m_parent = this;
73 /// Clone PDU Observer
74 new_observable->m_PDU_Observer =
75 m_PDU_Observer->sessionNotify(new_observable, cs_fileno(cs));
78 t_id = _beginthread (events, 0, socket_observable);
81 yaz_log (YLOG_FATAL|YLOG_ERRNO, "_beginthread failed");
87 int id = pthread_create (&tid, 0, events, socket_observable);
89 yaz_log (YLOG_ERRNO|YLOG_FATAL, "pthread_create returned id=%d", id);