fixed problem in bandwidth_manager

This commit is contained in:
Arvid Norberg 2007-09-19 06:06:18 +00:00
parent abbe3c774f
commit b0d51950b6
1 changed files with 9 additions and 13 deletions

View File

@ -180,12 +180,8 @@ struct bandwidth_manager
, m_limit(bandwidth_limit::inf) , m_limit(bandwidth_limit::inf)
, m_current_quota(0) , m_current_quota(0)
, m_channel(channel) , m_channel(channel)
{ , m_in_hand_out_bandwidth(false)
{}
#ifndef NDEBUG
m_in_hand_out_bandwidth = false;
#endif
}
void throttle(int limit) throw() void throttle(int limit) throw()
{ {
@ -333,10 +329,11 @@ private:
void hand_out_bandwidth() throw() void hand_out_bandwidth() throw()
{ {
#ifndef NDEBUG // if we're already handing out bandwidth, just return back
assert(m_in_hand_out_bandwidth == false); // to the loop further down on the callstack
if (m_in_hand_out_bandwidth) return;
m_in_hand_out_bandwidth = true; m_in_hand_out_bandwidth = true;
#ifndef NDEBUG
try { try {
#endif #endif
INVARIANT_CHECK; INVARIANT_CHECK;
@ -451,9 +448,8 @@ private:
} }
catch (std::exception& e) catch (std::exception& e)
{ assert(false); }; { assert(false); };
m_in_hand_out_bandwidth = false;
#endif #endif
m_in_hand_out_bandwidth = false;
} }
@ -487,9 +483,9 @@ private:
// that bandwidth is assigned to (upload or download) // that bandwidth is assigned to (upload or download)
int m_channel; int m_channel;
#ifndef NDEBUG // this is true while we're in the hand_out_bandwidth loop
// to prevent recursive invocations to interfere
bool m_in_hand_out_bandwidth; bool m_in_hand_out_bandwidth;
#endif
}; };