1 /* $Id: limit-connect.cpp,v 1.1 2006-03-30 10:35:15 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()
46 LimitConnect::~LimitConnect()
51 LimitConnect::Peer::Peer(int sz, const char *peername) : m_bw(sz)
53 m_peername = xstrdup(peername);
57 LimitConnect::Peer::~Peer()
62 void LimitConnect::Peer::add_connect()
67 LimitConnect::Peer **LimitConnect::lookup(const char *peername)
72 if (!strcmp((*p)->m_peername, peername))
79 void LimitConnect::add_connect(const char *peername)
81 Peer **p = lookup(peername);
83 *p = new Peer(m_period, peername);
87 int LimitConnect::get_total(const char *peername)
89 Peer **p = lookup(peername);
92 return (*p)->m_bw.get_total();
95 void LimitConnect::cleanup(bool all)
101 if (all || (tp->m_bw.get_total() == 0))
114 * indent-tabs-mode: nil
116 * vim: shiftwidth=4 tabstop=8 expandtab