X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/d58af85ce33b4b9c8cb065b59b591580ae8abe0c..ec5a129c62b75f939830c0585780bdedf7c78460:/lib/base/ebase.cpp diff --git a/lib/base/ebase.cpp b/lib/base/ebase.cpp index 038e5ad1..bcfab61c 100644 --- a/lib/base/ebase.cpp +++ b/lib/base/ebase.cpp @@ -6,6 +6,7 @@ #include #include +#include eSocketNotifier::eSocketNotifier(eMainloop *context, int fd, int requested, bool startnow): context(*context), fd(fd), state(0), requested(requested) { @@ -147,18 +148,15 @@ int eMainloop::processOneEvent(unsigned int twisted_timeout, PyObject **res, ePy long poll_timeout = -1; /* infinite in case of empty timer list */ - if (!m_timer_list.empty() || twisted_timeout > 0) + if (!m_timer_list.empty()) { - if (!m_timer_list.empty()) - { - /* process all timers which are ready. first remove them out of the list. */ - while (!m_timer_list.empty() && (poll_timeout = timeout_usec( m_timer_list.begin()->getNextActivation() ) ) <= 0 ) - m_timer_list.begin()->activate(); - if (poll_timeout < 0) - poll_timeout = 0; - else /* convert us to ms */ - poll_timeout /= 1000; - } + /* process all timers which are ready. first remove them out of the list. */ + while (!m_timer_list.empty() && (poll_timeout = timeout_usec( m_timer_list.begin()->getNextActivation() ) ) <= 0 ) + m_timer_list.begin()->activate(); + if (poll_timeout < 0) + poll_timeout = 0; + else /* convert us to ms */ + poll_timeout /= 1000; } if ((twisted_timeout > 0) && (poll_timeout > 0) && ((unsigned int)poll_timeout > twisted_timeout)) @@ -187,6 +185,11 @@ int eMainloop::processOneEvent(unsigned int twisted_timeout, PyObject **res, ePy if (additional) { +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) + typedef int Py_ssize_t; +# define PY_SSIZE_T_MAX INT_MAX +# define PY_SSIZE_T_MIN INT_MIN +#endif PyObject *key, *val; Py_ssize_t pos=0; while (PyDict_Next(additional, &pos, &key, &val)) { @@ -199,9 +202,14 @@ int eMainloop::processOneEvent(unsigned int twisted_timeout, PyObject **res, ePy if (this == eApp) { + gOpcode op; + op.dc = 0; + op.opcode = gOpcode::flush; + gRC::getInstance()->submit(op); Py_BEGIN_ALLOW_THREADS ret = ::poll(pfd, fdcount, poll_timeout); Py_END_ALLOW_THREADS + } else ret = ::poll(pfd, fdcount, poll_timeout); @@ -360,16 +368,19 @@ struct eTimerPy static int eTimerPy_traverse(eTimerPy *self, visitproc visit, void *arg) { - PyObject *obj = self->tm->timeout.get(); - Py_VISIT(obj); + PyObject *obj = self->tm->timeout.get(true); + if (obj) { + Py_VISIT(obj); + } return 0; } static int eTimerPy_clear(eTimerPy *self) { - PyObject *obj = self->tm->timeout.get(); - Py_CLEAR(obj); + PyObject *obj = self->tm->timeout.get(true); + if (obj) + Py_CLEAR(obj); return 0; } @@ -564,16 +575,18 @@ struct eSocketNotifierPy static int eSocketNotifierPy_traverse(eSocketNotifierPy *self, visitproc visit, void *arg) { - PyObject *obj = self->sn->activated.get(); - Py_VISIT(obj); + PyObject *obj = self->sn->activated.get(true); + if (obj) + Py_VISIT(obj); return 0; } static int eSocketNotifierPy_clear(eSocketNotifierPy *self) { - PyObject *obj = self->sn->activated.get(); - Py_CLEAR(obj); + PyObject *obj = self->sn->activated.get(true); + if (obj) + Py_CLEAR(obj); return 0; }