_ecore_glib_fds_resize(size_t size)
{
void *tmp = realloc(_ecore_glib_fds, sizeof(GPollFD) * size);
+
if (!tmp)
{
ERR("Could not realloc from %zu to %zu buckets.",
_ecore_glib_fds_size, size);
return EINA_FALSE;
}
-
+
_ecore_glib_fds = tmp;
_ecore_glib_fds_size = size;
return EINA_TRUE;
if (_ecore_glib_fds_size == 0)
{
- if (!_ecore_glib_fds_resize(ECORE_GLIB_FDS_INITIAL))
- return -1;
+ if (!_ecore_glib_fds_resize(ECORE_GLIB_FDS_INITIAL)) return -1;
}
-
+
while (1)
{
size_t size;
-
+
reqfds = g_main_context_query
(ctx, priority, p_timer, _ecore_glib_fds, _ecore_glib_fds_size);
- if (reqfds <= (int)_ecore_glib_fds_size)
- break;
+ if (reqfds <= (int)_ecore_glib_fds_size) break;
size = (1 + reqfds / ECORE_GLIB_FDS_STEP) * ECORE_GLIB_FDS_STEP;
- if (!_ecore_glib_fds_resize(size))
- return -1;
+ if (!_ecore_glib_fds_resize(size)) return -1;
}
if (reqfds + ECORE_GLIB_FDS_MAX_FREE < _ecore_glib_fds_size)
{
const GPollFD *itr = pfds, *itr_end = pfds + count;
int glib_fds = -1;
+
for (; itr < itr_end; itr++)
{
if (glib_fds < itr->fd)
_ecore_glib_context_poll_to(GPollFD *pfds, int count, const fd_set *rfds, const fd_set *wfds, const fd_set *efds, int ready)
{
GPollFD *itr = pfds, *itr_end = pfds + count;
+
for (; itr < itr_end && ready > 0; itr++)
{
itr->revents = 0;
g_main_context_prepare(ctx, &priority);
reqfds = _ecore_glib_context_query(ctx, priority, &reqtimeout);
- if (reqfds < 0)
- goto error;
+ if (reqfds < 0) goto error;
glib_fds = _ecore_glib_context_poll_from
(_ecore_glib_fds, reqfds, rfds, wfds, efds);
if (reqtimeout == -1)
timeout = ecore_timeout;
- else {
- glib_timeout.tv_sec = reqtimeout / 1000;
- glib_timeout.tv_usec = (reqtimeout % 1000) * 1000;
-
- if (!ecore_timeout || timercmp(ecore_timeout, &glib_timeout, >))
- timeout = &glib_timeout;
- else
- timeout = ecore_timeout;
- }
+ else
+ {
+ glib_timeout.tv_sec = reqtimeout / 1000;
+ glib_timeout.tv_usec = (reqtimeout % 1000) * 1000;
+
+ if (!ecore_timeout || timercmp(ecore_timeout, &glib_timeout, >))
+ timeout = &glib_timeout;
+ else
+ timeout = ecore_timeout;
+ }
maxfds = (ecore_fds >= glib_fds) ? ecore_fds : glib_fds;
ret = _ecore_glib_select_original(maxfds, rfds, wfds, efds, timeout);
_ecore_glib_shutdown(void)
{
#ifdef HAVE_GLIB
- if (!_ecore_glib_active)
- return;
+ if (!_ecore_glib_active) return;
_ecore_glib_active = EINA_FALSE;
if (ecore_main_loop_select_func_get() == _ecore_glib_select)
ecore_main_loop_select_func_set(_ecore_glib_select_original);
-
+
if (_ecore_glib_fds)
{
free(_ecore_glib_fds);