From: 이병우 <bw80.lee@samsung.com>
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 29 Mar 2012 10:36:23 +0000 (10:36 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 29 Mar 2012 10:36:23 +0000 (10:36 +0000)
commit4eb87c37973d3538d5220e1280d80537fb9ab2f2
tree19a56eb64bb912212ecdf0d1402d5cb0226d7a4b
parent562d09611e203e2820236c4a428b622e92e76b7e
From: 이병우 <bw80.lee@samsung.com>

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