2 * Copyright (c) 1998-2004, Index Data.
3 * See the file LICENSE for details.
5 * $Id: yaz-pdu-assoc-thread.cpp,v 1.12 2005-06-25 15:53:19 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 PDU_AssocThread::PDU_AssocThread(
39 ISocketObservable *socketObservable)
40 : PDU_Assoc(socketObservable)
52 SocketManager *s = (SocketManager *) p;
54 yaz_log (YLOG_LOG, "thread started");
55 while (s->processEvent() > 0)
57 yaz_log (YLOG_LOG, "thread finished");
64 void PDU_AssocThread::childNotify(COMSTACK cs)
66 SocketManager *socket_observable = new SocketManager;
67 PDU_Assoc *new_observable = new 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);
98 * indent-tabs-mode: nil
100 * vim: shiftwidth=4 tabstop=8 expandtab