don't get stuck if clock is reset back

This commit is contained in:
David Rose 2003-04-19 13:33:48 +00:00
parent 106d8cb648
commit f15bd7ba4f
2 changed files with 32 additions and 6 deletions

View File

@ -113,10 +113,19 @@ get_collect_tcp_interval() const {
////////////////////////////////////////////////////////////////////
INLINE bool OSocketStream::
consider_flush() {
if (!_collect_tcp ||
ClockObject::get_global_clock()->get_real_time() - _queued_data_start >= _collect_tcp_interval) {
if (!_collect_tcp) {
return flush();
} else {
double elapsed =
ClockObject::get_global_clock()->get_real_time() - _queued_data_start;
// If the elapsed time is negative, someone must have reset the
// clock back, so just go ahead and flush.
if (elapsed < 0.0 || elapsed >= _collect_tcp_interval) {
return flush();
}
}
return true;
}
@ -221,10 +230,19 @@ get_collect_tcp_interval() const {
////////////////////////////////////////////////////////////////////
INLINE bool SocketStream::
consider_flush() {
if (!_collect_tcp ||
ClockObject::get_global_clock()->get_real_time() - _queued_data_start >= _collect_tcp_interval) {
if (!_collect_tcp) {
return flush();
} else {
double elapsed =
ClockObject::get_global_clock()->get_real_time() - _queued_data_start;
// If the elapsed time is negative, someone must have reset the
// clock back, so just go ahead and flush.
if (elapsed < 0.0 || elapsed >= _collect_tcp_interval) {
return flush();
}
}
return true;
}

View File

@ -183,9 +183,17 @@ bool Connection::
consider_flush() {
PR_Lock(_write_mutex);
if (!_collect_tcp ||
ClockObject::get_global_clock()->get_real_time() - _queued_data_start >= _collect_tcp_interval) {
if (!_collect_tcp) {
return do_flush();
} else {
double elapsed =
ClockObject::get_global_clock()->get_real_time() - _queued_data_start;
// If the elapsed time is negative, someone must have reset the
// clock back, so just go ahead and flush.
if (elapsed < 0.0 || elapsed >= _collect_tcp_interval) {
return do_flush();
}
}
PR_Unlock(_write_mutex);