1 /* This file is part of YAZ proxy
2 Copyright (C) 1998-2009 Index Data
4 YAZ proxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include <yazproxy/limit-connect.h>
23 #include <yaz/xmalloc.h>
25 struct LimitConnect::Peer {
26 friend class LimitConnect;
28 Peer(int sz, const char *peername);
37 LimitConnect::LimitConnect()
44 LimitConnect::~LimitConnect()
49 void LimitConnect::set_period(int sec)
54 LimitConnect::Peer::Peer(int sz, const char *peername) : m_bw(sz)
56 m_peername = xstrdup(peername);
60 LimitConnect::Peer::~Peer()
65 void LimitConnect::Peer::add_connect()
70 LimitConnect::Peer **LimitConnect::lookup(const char *peername)
75 if (!strcmp((*p)->m_peername, peername))
82 void LimitConnect::add_connect(const char *peername)
84 Peer **p = lookup(peername);
86 *p = new Peer(m_period, peername);
90 int LimitConnect::get_total(const char *peername)
92 Peer **p = lookup(peername);
95 return (*p)->m_bw.get_total();
98 void LimitConnect::cleanup(bool all)
104 if (all || (tp->m_bw.get_total() == 0))
117 * c-file-style: "Stroustrup"
118 * indent-tabs-mode: nil
120 * vim: shiftwidth=4 tabstop=8 expandtab