From: Adam Dickmeiss Date: Wed, 30 Aug 2006 10:48:52 +0000 (+0000) Subject: Fixed bug #645: Filter Frontend_net must set proper Origin value. X-Git-Tag: METAPROXY.1.0.7~90 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=daae7f857790a8826c1db2f0452c0a7d0ebb15e5;p=metaproxy-moved-to-github.git Fixed bug #645: Filter Frontend_net must set proper Origin value. Don't use inline for Origin class stuff. Move Origin stuff to separate source file. --- diff --git a/src/Makefile.am b/src/Makefile.am index c0a8584..3a115ac 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.51 2006-08-29 10:06:31 marc Exp $ +## $Id: Makefile.am,v 1.52 2006-08-30 10:48:52 adam Exp $ MAINTAINERCLEANFILES = Makefile.in config.in config.hpp @@ -27,7 +27,7 @@ libmetaproxy_la_SOURCES = \ filter_virt_db.cpp filter_virt_db.hpp \ filter_z3950_client.cpp filter_z3950_client.hpp \ gduutil.cpp gduutil.hpp \ - package.cpp package.hpp \ + origin.cpp package.cpp package.hpp \ pipe.cpp pipe.hpp \ plainfile.cpp \ router.hpp router_chain.hpp router_chain.cpp \ diff --git a/src/filter_frontend_net.cpp b/src/filter_frontend_net.cpp index 28a55a4..385494b 100644 --- a/src/filter_frontend_net.cpp +++ b/src/filter_frontend_net.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_frontend_net.cpp,v 1.20 2006-08-30 09:56:41 marc Exp $ +/* $Id: filter_frontend_net.cpp,v 1.21 2006-08-30 10:48:52 adam Exp $ Copyright (c) 2005-2006, Index Data. See the LICENSE file for details @@ -154,7 +154,10 @@ mp::ZAssocChild::ZAssocChild(yazpp_1::IPDU_Observable *PDU_Observable, m_no_requests = 0; m_delete_flag = false; m_package = package; - // TODO why is m_origin not set here someplace ?? MC ?? + const char *peername = PDU_Observable->getpeername(); + if (!peername) + peername = "unknown"; + m_origin.set_tcpip_address(std::string(peername), m_session.id()); } diff --git a/src/origin.cpp b/src/origin.cpp new file mode 100644 index 0000000..0def014 --- /dev/null +++ b/src/origin.cpp @@ -0,0 +1,44 @@ +/* $Id: origin.cpp,v 1.1 2006-08-30 10:48:52 adam Exp $ + Copyright (c) 2005-2006, Index Data. + + See the LICENSE file for details + */ + + +#include "config.hpp" +#include "package.hpp" + +#include + +namespace mp = metaproxy_1; + +mp::Origin::Origin() : type(API) +{ + origin_id = 0; +} + +void mp::Origin::set_tcpip_address(std::string addr, unsigned long s) +{ + address = addr; + origin_id = s; + type = TCPIP; +} + +std::ostream& std::operator<<(std::ostream& os, mp::Origin& o) +{ + if (o.address != "") + os << o.address; + else + os << "0"; + os << ":" << o.origin_id; + return os; +} + +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * c-file-style: "stroustrup" + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ diff --git a/src/package.cpp b/src/package.cpp index d5559d0..541b452 100644 --- a/src/package.cpp +++ b/src/package.cpp @@ -1,4 +1,4 @@ -/* $Id: package.cpp,v 1.14 2006-08-30 09:56:41 marc Exp $ +/* $Id: package.cpp,v 1.15 2006-08-30 10:48:52 adam Exp $ Copyright (c) 2005-2006, Index Data. See the LICENSE file for details @@ -126,16 +126,6 @@ std::ostream& std::operator<<(std::ostream& os, mp::Package& p) return os; } -std::ostream& std::operator<<(std::ostream& os, mp::Origin& o) -{ - if (o.address != "") - os << o.address; - else - os << "0"; - os << ":" << o.port; - return os; -} - /* * Local variables: diff --git a/src/package.hpp b/src/package.hpp index d1cc671..3fb632b 100644 --- a/src/package.hpp +++ b/src/package.hpp @@ -1,4 +1,4 @@ -/* $Id: package.hpp,v 1.21 2006-08-30 09:56:41 marc Exp $ +/* $Id: package.hpp,v 1.22 2006-08-30 10:48:52 adam Exp $ Copyright (c) 2005-2006, Index Data. See the LICENSE file for details @@ -40,10 +40,10 @@ namespace metaproxy_1 { TCPIP } type; std::string address; // UNIX+TCPIP - int port; // TCPIP only + unsigned long origin_id; public: - Origin() : type(API) {}; - + Origin(); + void set_tcpip_address(std::string addr, unsigned long id); }; class Package {