Skip to content

Commit 8b613d0

Browse files
committed
fix EM.stop latency when timers exist (closes eventmachine#426)
1 parent 1427a2c commit 8b613d0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ext/em.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ EventMachine_t::_TimeTilNextEvent
687687

688688
timeval EventMachine_t::_TimeTilNextEvent()
689689
{
690-
// 29jul11: Changed calculation base from MyCurrentLoopTime to the
690+
// 29jul11: Changed calculation base from MyCurrentLoopTime to the
691691
// real time. As MyCurrentLoopTime is set at the beginning of an
692692
// iteration and this calculation is done at the end, evenmachine
693693
// will potentially oversleep by the amount of time the iteration
@@ -709,10 +709,12 @@ timeval EventMachine_t::_TimeTilNextEvent()
709709
if (!NewDescriptors.empty() || !ModifiedDescriptors.empty()) {
710710
next_event = current_time;
711711
}
712-
712+
713713
timeval tv;
714714

715-
if (next_event == 0 || NumCloseScheduled > 0) {
715+
if (NumCloseScheduled > 0 || bTerminateSignalReceived) {
716+
tv.tv_sec = tv.tv_usec = 0;
717+
} else if (next_event == 0) {
716718
tv = Quantum;
717719
} else {
718720
if (next_event > current_time) {

0 commit comments

Comments
 (0)