X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=src%2Ffilter_frontend_net.cpp;h=38ed62bd8fb8517acff375037fef8c6905649528;hb=0ab6e8aba7de1ea5cf109de175f56c9d8f7f49bc;hp=8b0e7117c554822c43fd4663013475d3c449f2e1;hpb=1e61b0aa05e2351e33d909f7503eaf936a2d9bb0;p=metaproxy-moved-to-github.git diff --git a/src/filter_frontend_net.cpp b/src/filter_frontend_net.cpp index 8b0e711..38ed62b 100644 --- a/src/filter_frontend_net.cpp +++ b/src/filter_frontend_net.cpp @@ -1,7 +1,22 @@ -/* $Id: filter_frontend_net.cpp,v 1.19 2006-06-10 14:29:12 adam Exp $ - Copyright (c) 2005-2006, Index Data. +/* $Id: filter_frontend_net.cpp,v 1.24 2007-05-09 21:23:09 adam Exp $ + Copyright (c) 2005-2007, Index Data. - See the LICENSE file for details +This file is part of Metaproxy. + +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Metaproxy; see the file LICENSE. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ #include "config.hpp" @@ -28,6 +43,7 @@ namespace metaproxy_1 { int m_no_threads; std::vector m_ports; int m_listen_duration; + int m_session_timeout; }; } class My_Timer_Thread : public yazpp_1::ISocketObserver { @@ -81,7 +97,8 @@ namespace metaproxy_1 { ~ZAssocServer(); ZAssocServer(yazpp_1::IPDU_Observable *PDU_Observable, mp::ThreadPoolSocketObserver *m_thread_pool_observer, - const mp::Package *package); + const mp::Package *package, + int timeout); private: yazpp_1::IPDU_Observer* sessionNotify( yazpp_1::IPDU_Observable *the_PDU_Observable, @@ -94,6 +111,7 @@ namespace metaproxy_1 { private: mp::ThreadPoolSocketObserver *m_thread_pool_observer; const mp::Package *m_package; + int m_session_timeout; }; } @@ -154,6 +172,10 @@ mp::ZAssocChild::ZAssocChild(yazpp_1::IPDU_Observable *PDU_Observable, m_no_requests = 0; m_delete_flag = false; m_package = package; + const char *peername = PDU_Observable->getpeername(); + if (!peername) + peername = "unknown"; + m_origin.set_tcpip_address(std::string(peername), m_session.id()); } @@ -206,9 +228,10 @@ void mp::ZAssocChild::connectNotify() } mp::ZAssocServer::ZAssocServer(yazpp_1::IPDU_Observable *PDU_Observable, - mp::ThreadPoolSocketObserver *thread_pool_observer, - const mp::Package *package) - : Z_Assoc(PDU_Observable) + mp::ThreadPoolSocketObserver *thread_pool_observer, + const mp::Package *package, + int timeout) + : Z_Assoc(PDU_Observable), m_session_timeout(timeout) { m_thread_pool_observer = thread_pool_observer; m_package = package; @@ -221,6 +244,7 @@ yazpp_1::IPDU_Observer *mp::ZAssocServer::sessionNotify(yazpp_1::IPDU_Observable mp::ZAssocChild *my = new mp::ZAssocChild(the_PDU_Observable, m_thread_pool_observer, m_package); + my->timeout(m_session_timeout); return my; } @@ -248,6 +272,7 @@ mp::filter::FrontendNet::FrontendNet() : m_p(new Rep) { m_p->m_no_threads = 5; m_p->m_listen_duration = 0; + m_p->m_session_timeout = 300; // 5 minutes } mp::filter::FrontendNet::~FrontendNet() @@ -297,7 +322,8 @@ void mp::filter::FrontendNet::process(Package &package) const yazpp_1::PDU_Assoc *as = new yazpp_1::PDU_Assoc(&mySocketManager); // create ZAssoc with PDU Assoc - az[i] = new mp::ZAssocServer(as, &threadPool, &package); + az[i] = new mp::ZAssocServer(as, &threadPool, &package, + m_p->m_session_timeout); az[i]->server(m_p->m_ports[i].c_str()); } while (mySocketManager.processEvent() > 0) @@ -338,6 +364,15 @@ void mp::filter::FrontendNet::configure(const xmlNode * ptr) + threads_str); m_p->m_no_threads = threads; } + else if (!strcmp((const char *) ptr->name, "timeout")) + { + std::string timeout_str = mp::xml::get_text(ptr); + int timeout = atoi(timeout_str.c_str()); + if (timeout < 1) + throw mp::filter::FilterException("Bad value for timeout: " + + timeout_str); + m_p->m_session_timeout = timeout; + } else { throw mp::filter::FilterException("Bad element "