1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
32 #include <yaz/tcpip.h>
34 #include <yazpp/pdu-assoc.h>
35 #include <yazpp/socket-manager.h>
37 using namespace yazpp_1;
46 PDU_AssocThread::PDU_AssocThread(
47 ISocketObservable *socketObservable)
48 : PDU_Assoc(socketObservable)
53 PDU_AssocThread::~PDU_AssocThread()
60 yaz_log (YLOG_LOG, "thread started");
61 while (this->m_mgr->processEvent() > 0)
63 yaz_log (YLOG_LOG, "thread finished");
75 worker *w = (worker *) p;
83 void PDU_AssocThread::childNotify(COMSTACK cs)
85 SocketManager *socket_observable = new SocketManager;
86 PDU_Assoc *new_observable = new PDU_Assoc (socket_observable, cs);
88 /// Clone PDU Observer
89 new_observable->m_PDU_Observer =
90 m_PDU_Observer->sessionNotify(new_observable, cs_fileno(cs));
92 if (!new_observable->m_PDU_Observer)
94 new_observable->shutdown();
95 delete new_observable;
96 delete socket_observable;
100 worker *w = new worker;
101 w->m_assoc = new_observable;
102 w->m_mgr = socket_observable;
106 t_id = _beginthread (events, 0, w);
109 yaz_log (YLOG_FATAL|YLOG_ERRNO, "_beginthread failed");
115 int id = pthread_create (&tid, 0, events, w);
117 yaz_log (YLOG_ERRNO|YLOG_FATAL, "pthread_create returned id=%d", id);
119 pthread_detach (tid);
126 * c-file-style: "Stroustrup"
127 * indent-tabs-mode: nil
129 * vim: shiftwidth=4 tabstop=8 expandtab