1 /* $Id: p2.cpp,v 1.3 2005-10-08 23:29:32 adam Exp $
2 Copyright (c) 1998-2005, Index Data.
4 This file is part of the yaz-proxy.
6 YAZ proxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with YAZ proxy; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 #include <yaz/diagbib1.h>
26 #include <yaz/options.h>
29 #include <yaz++/socket-manager.h>
30 #include "p2_config.h"
31 #include "p2_frontend.h"
32 #include "p2_xmlerror.h"
33 #include "p2_modules.h"
35 using namespace yazpp_1;
37 extern P2_ModuleEntry *p2_backend_dummy;
40 frontend result set map
43 backend result set map
44 db,query -> resultset, target
49 P2_Config *P2_Server::lockConfig()
51 pthread_mutex_lock(&m_mutex_config);
55 void P2_Server::unlockConfig()
57 pthread_mutex_unlock(&m_mutex_config);
60 P2_Server::P2_Server(IPDU_Observable *the_PDU_Observable,
61 ThreadPoolSocketObserver *my_thread,
63 P2_ModuleFactory *modules)
64 : Z_Assoc(the_PDU_Observable)
66 m_my_thread = my_thread;
70 pthread_mutex_init(&m_mutex_config, 0);
72 yaz_log(YLOG_LOG, "Construct P2_Server=%p", this);
75 IPDU_Observer *P2_Server::sessionNotify(IPDU_Observable
76 *the_PDU_Observable, int fd)
78 P2_Frontend *my = new P2_Frontend(the_PDU_Observable, m_my_thread, this);
79 yaz_log(YLOG_LOG, "New session %s", the_PDU_Observable->getpeername());
83 P2_Server::~P2_Server()
85 yaz_log(YLOG_LOG, "Destroy P2_server=%p", this);
86 pthread_mutex_destroy(&m_mutex_config);
89 void P2_Server::recv_GDU(Z_GDU *apdu, int len)
93 void P2_Server::failNotify()
97 void P2_Server::timeoutNotify()
101 void P2_Server::connectNotify()
105 int main(int argc, char **argv)
111 if (!config.parse_options(argc, argv))
113 yaz_log(YLOG_FATAL, "Configuration incorrect. Exiting");
117 SocketManager mySocketManager;
119 PDU_Assoc *my_PDU_Assoc = 0;
121 ThreadPoolSocketObserver my_thread(&mySocketManager, config.m_no_threads);
123 my_PDU_Assoc = new PDU_Assoc(&mySocketManager);
125 P2_ModuleFactory modules;
127 modules.add(p2_backend_dummy);
129 std::list<P2_ConfigModule *>::const_iterator it;
130 for (it = config.m_modules.begin(); it != config.m_modules.end(); it++)
131 modules.add((*it)->m_fname.c_str());
133 P2_Server z(my_PDU_Assoc, &my_thread, &config, &modules);
134 z.server(config.m_listen_address.c_str());
136 while (mySocketManager.processEvent() > 0)
143 * indent-tabs-mode: nil
145 * vim: shiftwidth=4 tabstop=8 expandtab