1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2009 Index Data and Mike Taylor
3 * See the file LICENSE for details.
29 #include <yaz/tcpip.h>
31 #include <yazpp/pdu-assoc.h>
32 #include <yazpp/socket-manager.h>
34 using namespace yazpp_1;
43 PDU_AssocThread::PDU_AssocThread(
44 ISocketObservable *socketObservable)
45 : PDU_Assoc(socketObservable)
52 yaz_log (YLOG_LOG, "thread started");
53 while (this->m_mgr->processEvent() > 0)
55 yaz_log (YLOG_LOG, "thread finished");
67 worker *w = (worker *) p;
75 void PDU_AssocThread::childNotify(COMSTACK cs)
77 SocketManager *socket_observable = new SocketManager;
78 PDU_Assoc *new_observable = new PDU_Assoc (socket_observable, cs);
80 /// Clone PDU Observer
81 new_observable->m_PDU_Observer =
82 m_PDU_Observer->sessionNotify(new_observable, cs_fileno(cs));
84 if (!new_observable->m_PDU_Observer)
86 new_observable->shutdown();
87 delete new_observable;
88 delete socket_observable;
92 worker *w = new worker;
93 w->m_assoc = new_observable;
94 w->m_mgr = socket_observable;
98 t_id = _beginthread (events, 0, w);
101 yaz_log (YLOG_FATAL|YLOG_ERRNO, "_beginthread failed");
107 int id = pthread_create (&tid, 0, events, w);
109 yaz_log (YLOG_ERRNO|YLOG_FATAL, "pthread_create returned id=%d", id);
111 pthread_detach (tid);
118 * c-file-style: "Stroustrup"
119 * indent-tabs-mode: nil
121 * vim: shiftwidth=4 tabstop=8 expandtab