2 * Copyright (c) 1998-2004, Index Data.
3 * See the file LICENSE for details.
5 * $Id: yaz-pdu-assoc-thread.cpp,v 1.15 2006-03-30 11:58:00 adam Exp $
31 #include <yaz/tcpip.h>
33 #include <yazpp/pdu-assoc.h>
34 #include <yazpp/socket-manager.h>
36 using namespace yazpp_1;
45 PDU_AssocThread::PDU_AssocThread(
46 ISocketObservable *socketObservable)
47 : PDU_Assoc(socketObservable)
54 yaz_log (YLOG_LOG, "thread started");
55 while (this->m_mgr->processEvent() > 0)
57 yaz_log (YLOG_LOG, "thread finished");
69 worker *w = (worker *) p;
77 void PDU_AssocThread::childNotify(COMSTACK cs)
79 SocketManager *socket_observable = new SocketManager;
80 PDU_Assoc *new_observable = new PDU_Assoc (socket_observable, cs);
82 /// Clone PDU Observer
83 new_observable->m_PDU_Observer =
84 m_PDU_Observer->sessionNotify(new_observable, cs_fileno(cs));
86 if (!new_observable->m_PDU_Observer)
88 new_observable->close();
89 delete new_observable;
90 delete socket_observable;
94 worker *w = new worker;
95 w->m_assoc = new_observable;
96 w->m_mgr = socket_observable;
100 t_id = _beginthread (events, 0, w);
103 yaz_log (YLOG_FATAL|YLOG_ERRNO, "_beginthread failed");
109 int id = pthread_create (&tid, 0, events, w);
111 yaz_log (YLOG_ERRNO|YLOG_FATAL, "pthread_create returned id=%d", id);
113 pthread_detach (tid);
120 * indent-tabs-mode: nil
122 * vim: shiftwidth=4 tabstop=8 expandtab