1 /* $Id: p2.cpp,v 1.5 2005-10-15 14:09:09 adam Exp $
2 Copyright (c) 2005, Index Data.
6 /* $Id: p2.cpp,v 1.5 2005-10-15 14:09:09 adam Exp $
7 Copyright (c) 1998-2005, Index Data.
9 This file is part of the yaz-proxy.
11 YAZ proxy is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free
13 Software Foundation; either version 2, or (at your option) any later
16 YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
17 WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with YAZ proxy; see the file LICENSE. If not, write to the
23 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
30 #include <yaz/diagbib1.h>
31 #include <yaz/options.h>
34 #include <yaz++/socket-manager.h>
35 #include "p2_config.h"
36 #include "p2_frontend.h"
37 #include "p2_xmlerror.h"
38 #include "p2_modules.h"
40 using namespace yazpp_1;
42 extern P2_ModuleEntry *p2_backend_dummy;
45 frontend result set map
48 backend result set map
49 db,query -> resultset, target
54 P2_Config *P2_Server::lockConfig()
56 pthread_mutex_lock(&m_mutex_config);
60 void P2_Server::unlockConfig()
62 pthread_mutex_unlock(&m_mutex_config);
65 P2_Server::P2_Server(IPDU_Observable *the_PDU_Observable,
66 yp2::ThreadPoolSocketObserver *my_thread,
68 P2_ModuleFactory *modules)
69 : Z_Assoc(the_PDU_Observable)
71 m_my_thread = my_thread;
75 pthread_mutex_init(&m_mutex_config, 0);
77 yaz_log(YLOG_LOG, "Construct P2_Server=%p", this);
80 IPDU_Observer *P2_Server::sessionNotify(IPDU_Observable
81 *the_PDU_Observable, int fd)
83 P2_Frontend *my = new P2_Frontend(the_PDU_Observable, m_my_thread, this);
84 yaz_log(YLOG_LOG, "New session %s", the_PDU_Observable->getpeername());
88 P2_Server::~P2_Server()
90 yaz_log(YLOG_LOG, "Destroy P2_server=%p", this);
91 pthread_mutex_destroy(&m_mutex_config);
94 void P2_Server::recv_GDU(Z_GDU *apdu, int len)
98 void P2_Server::failNotify()
102 void P2_Server::timeoutNotify()
106 void P2_Server::connectNotify()
110 int main(int argc, char **argv)
116 if (!config.parse_options(argc, argv))
118 yaz_log(YLOG_FATAL, "Configuration incorrect. Exiting");
122 SocketManager mySocketManager;
124 PDU_Assoc *my_PDU_Assoc = 0;
126 yp2::ThreadPoolSocketObserver my_thread(&mySocketManager,
127 config.m_no_threads);
129 my_PDU_Assoc = new PDU_Assoc(&mySocketManager);
131 P2_ModuleFactory modules;
133 modules.add(p2_backend_dummy);
135 std::list<P2_ConfigModule *>::const_iterator it;
136 for (it = config.m_modules.begin(); it != config.m_modules.end(); it++)
137 modules.add((*it)->m_fname.c_str());
139 P2_Server z(my_PDU_Assoc, &my_thread, &config, &modules);
140 z.server(config.m_listen_address.c_str());
142 while (mySocketManager.processEvent() > 0)
149 * indent-tabs-mode: nil
150 * c-file-style: "stroustrup"
152 * vim: shiftwidth=4 tabstop=8 expandtab