1 /* $Id: p2.cpp,v 1.2 2005-10-06 19:33:58 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>
28 #include <yaz++/socket-manager.h>
29 #include "p2_config.h"
30 #include "p2_frontend.h"
31 #include "p2_xmlerror.h"
32 #include "p2_modules.h"
34 using namespace yazpp_1;
36 extern P2_ModuleEntry *p2_backend_dummy;
39 frontend result set map
42 backend result set map
43 db,query -> resultset, target
48 P2_Config *P2_Server::lockConfig()
50 pthread_mutex_lock(&m_mutex_config);
54 void P2_Server::unlockConfig()
56 pthread_mutex_unlock(&m_mutex_config);
59 P2_Server::P2_Server(IPDU_Observable *the_PDU_Observable,
60 ThreadPoolSocketObserver *my_thread,
62 P2_ModuleFactory *modules)
63 : Z_Assoc(the_PDU_Observable)
65 m_my_thread = my_thread;
69 pthread_mutex_init(&m_mutex_config, 0);
71 yaz_log(YLOG_LOG, "Construct P2_Server=%p", this);
74 IPDU_Observer *P2_Server::sessionNotify(IPDU_Observable
75 *the_PDU_Observable, int fd)
77 P2_Frontend *my = new P2_Frontend(the_PDU_Observable, m_my_thread, this);
78 yaz_log(YLOG_LOG, "New session %s", the_PDU_Observable->getpeername());
82 P2_Server::~P2_Server()
84 yaz_log(YLOG_LOG, "Destroy P2_server=%p", this);
85 pthread_mutex_destroy(&m_mutex_config);
88 void P2_Server::recv_GDU(Z_GDU *apdu, int len)
92 void P2_Server::failNotify()
96 void P2_Server::timeoutNotify()
100 void P2_Server::connectNotify()
104 int main(int argc, char **argv)
110 if (!config.parse_options(argc, argv))
112 yaz_log(YLOG_FATAL, "Configuration incorrect. Exiting");
116 SocketManager mySocketManager;
118 PDU_Assoc *my_PDU_Assoc = 0;
120 ThreadPoolSocketObserver my_thread(&mySocketManager, config.m_no_threads);
122 my_PDU_Assoc = new PDU_Assoc(&mySocketManager);
124 P2_ModuleFactory modules;
126 modules.add(p2_backend_dummy);
128 std::list<P2_ConfigModule *>::const_iterator it;
129 for (it = config.m_modules.begin(); it != config.m_modules.end(); it++)
130 modules.add((*it)->m_fname.c_str());
132 P2_Server z(my_PDU_Assoc, &my_thread, &config, &modules);
133 z.server(config.m_listen_address.c_str());
135 while (mySocketManager.processEvent() > 0)
142 * indent-tabs-mode: nil
144 * vim: shiftwidth=4 tabstop=8 expandtab