ev.c fix

Auxten wpc auxtenwpc at gmail.com
Wed Sep 7 09:27:41 CEST 2011


oh, i missed some lines
my patch is as below:

*** libev-4.04/ev.c     2011-02-09 07:17:37.000000000 +0800
--- libev-4.04-fixed/ev.c       2011-09-07 15:17:31.000000000 +0800
***************
*** 948,953 ****
--- 948,955 ----

        if (ev)
          ev_feed_event (EV_A_ (W)w, ev);
+       if (w == (ev_io *)((WL)w)->next)
+         break;
      }
  }

***************
*** 1017,1023 ****
            anfd->events = 0;

            for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next)
!             anfd->events |= (unsigned char)w->events;

            if (o_events != anfd->events)
              o_reify = EV__IOFDSET; /* actually |= */
--- 1019,1029 ----
            anfd->events = 0;

            for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next)
!             {
!               anfd->events |= (unsigned char)w->events;
!               if (w == (ev_io *)((WL)w)->next)
!                 break;
!             }

            if (o_events != anfd->events)
              o_reify = EV__IOFDSET; /* actually |= */
***************
*** 1495,1500 ****
--- 1501,1508 ----
            w->rstatus = status;
            ev_feed_event (EV_A_ (W)w, EV_CHILD);
          }
+       if (w == (ev_child *)((WL)w)->next)
+         break;
      }
  }



2011/9/7 Auxten wpc <auxtenwpc at gmail.com>

> libev-4.04 may have a infi loop at ev.c line 1020,1019
>
>           for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next)
>>               anfd->events |= (unsigned char)w->events;
>>
>
> as my trace there a possiblity "w == (ev_io *)((WL)w)->next", the next
> point to itself
> this cause one of my threads infi loop here, so the simple fix is
>
> diff -r libev-4.04/ev.c libev-4.04-fixed/ev.c
>
>> 1020c1020,1024
>> <             anfd->events |= (unsigned char)w->events;
>> ---
>> >             {
>> >               anfd->events |= (unsigned char)w->events;
>> >               if (w == (ev_io *)((WL)w)->next)
>> >                 break;
>> >             }
>>
>
>
>
> --
> ----------------------------------
> Auxten *StarDust* blog.auxten.com
>



-- 
----------------------------------
Auxten *StarDust* blog.auxten.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20110907/efa8d2da/attachment.html>


More information about the libev mailing list