ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.181 by root, Wed Dec 12 00:17:08 2007 UTC vs.
Revision 1.184 by root, Wed Dec 12 05:30:52 2007 UTC

533 { 533 {
534 int fd = fdchanges [i]; 534 int fd = fdchanges [i];
535 ANFD *anfd = anfds + fd; 535 ANFD *anfd = anfds + fd;
536 ev_io *w; 536 ev_io *w;
537 537
538 int events = 0; 538 unsigned char events = 0;
539 539
540 for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) 540 for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next)
541 events |= w->events; 541 events |= (unsigned char)w->events;
542 542
543#if EV_SELECT_IS_WINSOCKET 543#if EV_SELECT_IS_WINSOCKET
544 if (events) 544 if (events)
545 { 545 {
546 unsigned long argp; 546 unsigned long argp;
547 anfd->handle = _get_osfhandle (fd); 547 anfd->handle = _get_osfhandle (fd);
548 assert (("libev only supports socket fds in this configuration", ioctlsocket (anfd->handle, FIONREAD, &argp) == 0)); 548 assert (("libev only supports socket fds in this configuration", ioctlsocket (anfd->handle, FIONREAD, &argp) == 0));
549 } 549 }
550#endif 550#endif
551 551
552 {
553 unsigned char o_events = anfd->events;
554 unsigned char o_reify = anfd->reify;
555
552 anfd->reify = 0; 556 anfd->reify = 0;
553
554 backend_modify (EV_A_ fd, anfd->events, events);
555 anfd->events = events; 557 anfd->events = events;
558
559 if (o_events != events || o_reify & EV_IOFDSET)
560 backend_modify (EV_A_ fd, o_events, events);
561 }
556 } 562 }
557 563
558 fdchangecnt = 0; 564 fdchangecnt = 0;
559} 565}
560 566
561void inline_size 567void inline_size
562fd_change (EV_P_ int fd) 568fd_change (EV_P_ int fd, int flags)
563{ 569{
564 if (expect_false (anfds [fd].reify)) 570 unsigned char reify = anfds [fd].reify;
565 return;
566
567 anfds [fd].reify = 1; 571 anfds [fd].reify |= flags;
568 572
573 if (expect_true (!reify))
574 {
569 ++fdchangecnt; 575 ++fdchangecnt;
570 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2); 576 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2);
571 fdchanges [fdchangecnt - 1] = fd; 577 fdchanges [fdchangecnt - 1] = fd;
578 }
572} 579}
573 580
574void inline_speed 581void inline_speed
575fd_kill (EV_P_ int fd) 582fd_kill (EV_P_ int fd)
576{ 583{
627 634
628 for (fd = 0; fd < anfdmax; ++fd) 635 for (fd = 0; fd < anfdmax; ++fd)
629 if (anfds [fd].events) 636 if (anfds [fd].events)
630 { 637 {
631 anfds [fd].events = 0; 638 anfds [fd].events = 0;
632 fd_change (EV_A_ fd); 639 fd_change (EV_A_ fd, EV_IOFDSET | 1);
633 } 640 }
634} 641}
635 642
636/*****************************************************************************/ 643/*****************************************************************************/
637 644
792 ev_unref (EV_A); /* child watcher should not keep loop alive */ 799 ev_unref (EV_A); /* child watcher should not keep loop alive */
793} 800}
794 801
795/*****************************************************************************/ 802/*****************************************************************************/
796 803
797static ev_child *childs [EV_PID_HASHSIZE]; 804static WL childs [EV_PID_HASHSIZE];
798 805
799#ifndef _WIN32 806#ifndef _WIN32
800 807
801static ev_signal childev; 808static ev_signal childev;
802 809
1597 1604
1598 assert (("ev_io_start called with negative fd", fd >= 0)); 1605 assert (("ev_io_start called with negative fd", fd >= 0));
1599 1606
1600 ev_start (EV_A_ (W)w, 1); 1607 ev_start (EV_A_ (W)w, 1);
1601 array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init); 1608 array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init);
1602 wlist_add ((WL *)&anfds[fd].head, (WL)w); 1609 wlist_add (&anfds[fd].head, (WL)w);
1603 1610
1604 fd_change (EV_A_ fd); 1611 fd_change (EV_A_ fd, w->events & EV_IOFDSET | 1);
1612 w->events &= ~EV_IOFDSET;
1605} 1613}
1606 1614
1607void noinline 1615void noinline
1608ev_io_stop (EV_P_ ev_io *w) 1616ev_io_stop (EV_P_ ev_io *w)
1609{ 1617{
1611 if (expect_false (!ev_is_active (w))) 1619 if (expect_false (!ev_is_active (w)))
1612 return; 1620 return;
1613 1621
1614 assert (("ev_io_start called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax)); 1622 assert (("ev_io_start called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
1615 1623
1616 wlist_del ((WL *)&anfds[w->fd].head, (WL)w); 1624 wlist_del (&anfds[w->fd].head, (WL)w);
1617 ev_stop (EV_A_ (W)w); 1625 ev_stop (EV_A_ (W)w);
1618 1626
1619 fd_change (EV_A_ w->fd); 1627 fd_change (EV_A_ w->fd, 1);
1620} 1628}
1621 1629
1622void noinline 1630void noinline
1623ev_timer_start (EV_P_ ev_timer *w) 1631ev_timer_start (EV_P_ ev_timer *w)
1624{ 1632{
1766 sigprocmask (SIG_SETMASK, &prev, 0); 1774 sigprocmask (SIG_SETMASK, &prev, 0);
1767#endif 1775#endif
1768 } 1776 }
1769 1777
1770 ev_start (EV_A_ (W)w, 1); 1778 ev_start (EV_A_ (W)w, 1);
1771 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); 1779 wlist_add (&signals [w->signum - 1].head, (WL)w);
1772 1780
1773 if (!((WL)w)->next) 1781 if (!((WL)w)->next)
1774 { 1782 {
1775#if _WIN32 1783#if _WIN32
1776 signal (w->signum, sighandler); 1784 signal (w->signum, sighandler);
1789{ 1797{
1790 clear_pending (EV_A_ (W)w); 1798 clear_pending (EV_A_ (W)w);
1791 if (expect_false (!ev_is_active (w))) 1799 if (expect_false (!ev_is_active (w)))
1792 return; 1800 return;
1793 1801
1794 wlist_del ((WL *)&signals [w->signum - 1].head, (WL)w); 1802 wlist_del (&signals [w->signum - 1].head, (WL)w);
1795 ev_stop (EV_A_ (W)w); 1803 ev_stop (EV_A_ (W)w);
1796 1804
1797 if (!signals [w->signum - 1].head) 1805 if (!signals [w->signum - 1].head)
1798 signal (w->signum, SIG_DFL); 1806 signal (w->signum, SIG_DFL);
1799} 1807}
1806#endif 1814#endif
1807 if (expect_false (ev_is_active (w))) 1815 if (expect_false (ev_is_active (w)))
1808 return; 1816 return;
1809 1817
1810 ev_start (EV_A_ (W)w, 1); 1818 ev_start (EV_A_ (W)w, 1);
1811 wlist_add ((WL *)&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); 1819 wlist_add (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w);
1812} 1820}
1813 1821
1814void 1822void
1815ev_child_stop (EV_P_ ev_child *w) 1823ev_child_stop (EV_P_ ev_child *w)
1816{ 1824{
1817 clear_pending (EV_A_ (W)w); 1825 clear_pending (EV_A_ (W)w);
1818 if (expect_false (!ev_is_active (w))) 1826 if (expect_false (!ev_is_active (w)))
1819 return; 1827 return;
1820 1828
1821 wlist_del ((WL *)&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); 1829 wlist_del (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w);
1822 ev_stop (EV_A_ (W)w); 1830 ev_stop (EV_A_ (W)w);
1823} 1831}
1824 1832
1825#if EV_STAT_ENABLE 1833#if EV_STAT_ENABLE
1826 1834

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines