From 4eb87c37973d3538d5220e1280d80537fb9ab2f2 Mon Sep 17 00:00:00 2001 From: raster Date: Thu, 29 Mar 2012 10:36:23 +0000 Subject: [PATCH] =?utf8?q?From:=20=EC=9D=B4=EB=B3=91=EC=9A=B0=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit I found a bug in ecore main loop while debuging cpu 100% issue on RSS application. 1. [RSS] RSS application register two io watch callbacks(for G_IO_IN, G_IO_OUT seperately) for a GIOChannel with g_io_add_watch(). 2. [ecore] In _ecore_glib_context_query() function, g_main_context_query() returns a fd list, and it has 2 fd items for the GIOChannel (channel id = 20). itr[0] (16, 1, 0) itr[1] (15, 1, 0) itr[2] (20, 1, 0) (G_IO_IN, 0) itr[3] (20, 4, 0) (G_IO_OUT, 0) itr[4] (18, 1, 0) 3. [ecore] In _ecore_glib_context_poll_from() function, create read, write, exception fd list according to the events flags of each fd item. [6 15 16 18 20], [20], [] 4. [ecore] in _ecore_glib_select__locked() function, get active fd number from select() call select(21, [6 15 16 18 20], [20], [], NULL) = 1 (out [20]) 5. [ecore] In _ecore_glib_context_poll_to() function, there is a bug on setting revents flag. (because of incorrect condition check - currently, the logic of the function cannot handle this case) itr[0] (16, 1, 0) itr[1] (15, 1, 0) itr[2] (20, 1, 4) (set incorrectly) itr[3] (20, 4, 0) => this should be set as (20, 4, 4)!!!! itr[4] (18, 1, 0) 6. [ecore] In _ecore_glib_select__locked(), g_main_context_check() function returns false because of the above bug, so g_main_context_dispatch() function will not be called. >> After this, the 2~6 flow is executed repeatedly on ecore main loop (because 20 out is still active fd) and this makes cpu 100% problem. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@69739 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore/ecore_glib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/ecore/ecore_glib.c b/src/lib/ecore/ecore_glib.c index fd6a684..a4db0ab 100644 --- a/src/lib/ecore/ecore_glib.c +++ b/src/lib/ecore/ecore_glib.c @@ -111,17 +111,17 @@ _ecore_glib_context_poll_to(GPollFD *pfds, for (; (itr < itr_end) && (ready > 0); itr++) { itr->revents = 0; - if (FD_ISSET(itr->fd, rfds)) + if (FD_ISSET(itr->fd, rfds) && (itr->events & G_IO_IN)) { itr->revents |= G_IO_IN; ready--; } - if (FD_ISSET(itr->fd, wfds)) + if (FD_ISSET(itr->fd, wfds) && (itr->events & G_IO_OUT)) { itr->revents |= G_IO_OUT; ready--; } - if (FD_ISSET(itr->fd, efds)) + if (FD_ISSET(itr->fd, efds) && (itr->events & (G_IO_HUP | G_IO_ERR))) { itr->revents |= G_IO_ERR; ready--; -- 2.7.4