+int eMainloop::processOneEvent(unsigned int user_timeout, PyObject **res, PyObject *additional)
+{
+ int return_reason = 0;
+ /* get current time */
+ timeval now;
+ gettimeofday(&now, 0);
+ m_now_is_invalid = 0;
+
+ if (additional && !PyDict_Check(additional))
+ eFatal("additional, but it's not dict");
+
+ if (additional && !res)
+ eFatal("additional, but no res");
+
+ int poll_timeout = -1; /* infinite in case of empty timer list */
+
+ if (m_timer_list)
+ {
+ singleLock s(recalcLock);
+ poll_timeout = timeval_to_usec(m_timer_list.begin()->getNextActivation() - now);
+ /* if current timer already passed, don't delay infinite. */
+ if (poll_timeout < 0)
+ poll_timeout = 0;
+
+ /* convert us to ms */
+ poll_timeout /= 1000;
+ }
+
+ if ((user_timeout > 0) && (poll_timeout > 0) && ((unsigned int)poll_timeout > user_timeout))
+ {
+ poll_timeout = user_timeout;
+ return_reason = 1;
+ }
+
+ int ret = 0;
+
+ std::multimap<int,eSocketNotifier*>::iterator it;
+ std::map<int,int> fd_merged;
+ std::map<int,int>::const_iterator fd_merged_it;
+
+ for (it = notifiers.begin(); it != notifiers.end(); ++it)
+ fd_merged[it->first] |= it->second->getRequested();
+
+ fd_merged_it = fd_merged.begin();
+
+ int nativecount, fdcount;
+
+ nativecount = fdcount = fd_merged.size();
+
+ if (additional)
+ {
+ additional = PyDict_Items(additional);
+ fdcount += PyList_Size(additional);
+ }
+