2 * Copyright (c) 1998-2004, Index Data.
3 * See the file LICENSE for details.
5 * $Id: yaz-pdu-assoc-thread.cpp,v 1.9 2005-01-14 10:13:50 adam Exp $
31 #include <yaz/tcpip.h>
33 #include <yaz++/pdu-assoc.h>
34 #include <yaz++/socket-manager.h>
36 Yaz_PDU_AssocThread::Yaz_PDU_AssocThread(
37 IYazSocketObservable *socketObservable)
38 : Yaz_PDU_Assoc(socketObservable)
50 Yaz_SocketManager *s = (Yaz_SocketManager *) p;
52 yaz_log (YLOG_LOG, "thread started");
53 while (s->processEvent() > 0)
55 yaz_log (YLOG_LOG, "thread finished");
62 void Yaz_PDU_AssocThread::childNotify(COMSTACK cs)
64 Yaz_SocketManager *socket_observable = new Yaz_SocketManager;
65 Yaz_PDU_Assoc *new_observable = new Yaz_PDU_Assoc (socket_observable, cs);
67 new_observable->m_next = m_children;
68 m_children = new_observable;
69 new_observable->m_parent = this;
71 /// Clone PDU Observer
72 new_observable->m_PDU_Observer =
73 m_PDU_Observer->sessionNotify(new_observable, cs_fileno(cs));
76 t_id = _beginthread (events, 0, socket_observable);
79 yaz_log (YLOG_FATAL|YLOG_ERRNO, "_beginthread failed");
85 int id = pthread_create (&tid, 0, events, socket_observable);
87 yaz_log (YLOG_ERRNO|YLOG_FATAL, "pthread_create returned id=%d", id);