- /* notes:
- - we should use epoll(4)
- - timer are checked twice. there was a strong reason for it, but i can't remember. (FIXME)
- - for each time, we gettimeofday() and check wether the timer should fire.
- we should do this all better - we know how long the poll last, so we know which
- timers should fire. Problem is that a timer handler could have required so
- much time that another timer fired.
-
- A probably structure could look
-
- while (1)
- {
- time = gettimeofday()
- timeout = calculate_pending_timers(time);
-
- doPoll(timeout or infinite);
-
- if (poll_had_results)
- handle_poll_handler();
- else
- fire_timers(time + timeout)
- }
-
- the gettimeofday() call is required because fire_timers could last more
- than nothing.
-
- when poll did no timeout, we don't handle timers, as this will be done
- in the next iteration (without adding overhead - we had to get the new
- time anyway
- */
-
- // first, process pending timers...
- long usec=0;
-
- if ( TimerList )
- doRecalcTimers();
- while (TimerList && (usec = timeout_usec( TimerList.begin()->getNextActivation() ) ) <= 0 )
+ int return_reason = 0;
+ /* get current time */
+
+ if (additional && !PyDict_Check(additional))
+ eFatal("additional, but it's not dict");
+
+ if (additional && !res)
+ eFatal("additional, but no res");
+
+ long poll_timeout = -1; /* infinite in case of empty timer list */
+
+ if (!m_timer_list.empty() || twisted_timeout > 0)