Permalink
Browse files

fix EM.stop latency when timers exist (closes #426)

  • Loading branch information...
1 parent 1427a2c commit 8b613d05047ad6954f7d856b1404522214e8f001 @tmm1 tmm1 committed Apr 2, 2013
Showing with 5 additions and 3 deletions.
  1. +5 −3 ext/em.cpp
View
@@ -687,7 +687,7 @@ EventMachine_t::_TimeTilNextEvent
timeval EventMachine_t::_TimeTilNextEvent()
{
- // 29jul11: Changed calculation base from MyCurrentLoopTime to the
+ // 29jul11: Changed calculation base from MyCurrentLoopTime to the
// real time. As MyCurrentLoopTime is set at the beginning of an
// iteration and this calculation is done at the end, evenmachine
// will potentially oversleep by the amount of time the iteration
@@ -709,10 +709,12 @@ timeval EventMachine_t::_TimeTilNextEvent()
if (!NewDescriptors.empty() || !ModifiedDescriptors.empty()) {
next_event = current_time;
}
-
+
timeval tv;
- if (next_event == 0 || NumCloseScheduled > 0) {
+ if (NumCloseScheduled > 0 || bTerminateSignalReceived) {
+ tv.tv_sec = tv.tv_usec = 0;
+ } else if (next_event == 0) {
tv = Quantum;
} else {
if (next_event > current_time) {

2 comments on commit 8b613d0

@danielwaterworth

I have reason to believe that this commit may have introduced a bug that causes an infinite loop. NumCloseScheduled may be above zero persistently after a connection is closed.

@tmm1
Collaborator
tmm1 commented on 8b613d0 Apr 9, 2013

Can you open an issue with a repro case?

Please sign in to comment.