1 /* $Id: limit-connect.cpp,v 1.2 2006-04-06 16:25:21 adam Exp $
2 Copyright (c) 1998-2006, Index Data.
4 This file is part of the yazproxy.
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
22 #include <yazproxy/limit-connect.h>
26 #include <yaz/xmalloc.h>
28 struct LimitConnect::Peer {
29 friend class LimitConnect;
31 Peer(int sz, const char *peername);
40 LimitConnect::LimitConnect()
47 LimitConnect::~LimitConnect()
52 void LimitConnect::set_period(int sec)
57 LimitConnect::Peer::Peer(int sz, const char *peername) : m_bw(sz)
59 m_peername = xstrdup(peername);
63 LimitConnect::Peer::~Peer()
68 void LimitConnect::Peer::add_connect()
73 LimitConnect::Peer **LimitConnect::lookup(const char *peername)
78 if (!strcmp((*p)->m_peername, peername))
85 void LimitConnect::add_connect(const char *peername)
87 Peer **p = lookup(peername);
89 *p = new Peer(m_period, peername);
93 int LimitConnect::get_total(const char *peername)
95 Peer **p = lookup(peername);
98 return (*p)->m_bw.get_total();
101 void LimitConnect::cleanup(bool all)
107 if (all || (tp->m_bw.get_total() == 0))
120 * indent-tabs-mode: nil
122 * vim: shiftwidth=4 tabstop=8 expandtab