mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
don't get stuck if clock is reset back
This commit is contained in:
parent
106d8cb648
commit
f15bd7ba4f
@ -113,10 +113,19 @@ get_collect_tcp_interval() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE bool OSocketStream::
|
INLINE bool OSocketStream::
|
||||||
consider_flush() {
|
consider_flush() {
|
||||||
if (!_collect_tcp ||
|
if (!_collect_tcp) {
|
||||||
ClockObject::get_global_clock()->get_real_time() - _queued_data_start >= _collect_tcp_interval) {
|
|
||||||
return flush();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,10 +230,19 @@ get_collect_tcp_interval() const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE bool SocketStream::
|
INLINE bool SocketStream::
|
||||||
consider_flush() {
|
consider_flush() {
|
||||||
if (!_collect_tcp ||
|
if (!_collect_tcp) {
|
||||||
ClockObject::get_global_clock()->get_real_time() - _queued_data_start >= _collect_tcp_interval) {
|
|
||||||
return flush();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,9 +183,17 @@ bool Connection::
|
|||||||
consider_flush() {
|
consider_flush() {
|
||||||
PR_Lock(_write_mutex);
|
PR_Lock(_write_mutex);
|
||||||
|
|
||||||
if (!_collect_tcp ||
|
if (!_collect_tcp) {
|
||||||
ClockObject::get_global_clock()->get_real_time() - _queued_data_start >= _collect_tcp_interval) {
|
|
||||||
return do_flush();
|
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);
|
PR_Unlock(_write_mutex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user