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

Comparing libev/ev.c (file contents):
Revision 1.424 by root, Tue May 1 22:01:40 2012 UTC vs.
Revision 1.428 by root, Tue May 8 15:44:09 2012 UTC

202# include <unistd.h> 202# include <unistd.h>
203#else 203#else
204# include <io.h> 204# include <io.h>
205# define WIN32_LEAN_AND_MEAN 205# define WIN32_LEAN_AND_MEAN
206# include <windows.h> 206# include <windows.h>
207# include <winsock2.h>
207# ifndef EV_SELECT_IS_WINSOCKET 208# ifndef EV_SELECT_IS_WINSOCKET
208# define EV_SELECT_IS_WINSOCKET 1 209# define EV_SELECT_IS_WINSOCKET 1
209# endif 210# endif
210# undef EV_AVOID_STDIO 211# undef EV_AVOID_STDIO
211#endif 212#endif
1430 w_->pending = ++pendingcnt [pri]; 1431 w_->pending = ++pendingcnt [pri];
1431 array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, EMPTY2); 1432 array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, EMPTY2);
1432 pendings [pri][w_->pending - 1].w = w_; 1433 pendings [pri][w_->pending - 1].w = w_;
1433 pendings [pri][w_->pending - 1].events = revents; 1434 pendings [pri][w_->pending - 1].events = revents;
1434 } 1435 }
1436
1437 pendingpri = NUMPRI - 1;
1435} 1438}
1436 1439
1437inline_speed void 1440inline_speed void
1438feed_reverse (EV_P_ W w) 1441feed_reverse (EV_P_ W w)
1439{ 1442{
1874 write (evfd, &counter, sizeof (uint64_t)); 1877 write (evfd, &counter, sizeof (uint64_t));
1875 } 1878 }
1876 else 1879 else
1877#endif 1880#endif
1878 { 1881 {
1879 /* win32 people keep sending patches that change this write() to send() */ 1882#ifdef _WIN32
1880 /* and then run away. but send() is wrong, it wants a socket handle on win32 */ 1883 WSABUF buf;
1881 /* so when you think this write should be a send instead, please find out */ 1884 DWORD sent;
1882 /* where your send() is from - it's definitely not the microsoft send, and */ 1885 buf.buf = &buf;
1883 /* tell me. thank you. */ 1886 buf.len = 1;
1884 /* it might be that your problem is that your environment needs EV_USE_WSASOCKET */ 1887 WSASend (EV_FD_TO_WIN32_HANDLE (evpipe [1]), &buf, 1, &sent, 0, 0, 0);
1885 /* check the ev documentation on how to use this flag */ 1888#else
1886 write (evpipe [1], &(evpipe [1]), 1); 1889 write (evpipe [1], &(evpipe [1]), 1);
1890#endif
1887 } 1891 }
1888 1892
1889 errno = old_errno; 1893 errno = old_errno;
1890 } 1894 }
1891} 1895}
1906 read (evfd, &counter, sizeof (uint64_t)); 1910 read (evfd, &counter, sizeof (uint64_t));
1907 } 1911 }
1908 else 1912 else
1909#endif 1913#endif
1910 { 1914 {
1911 char dummy; 1915 char dummy[4];
1912 /* see discussion in evpipe_write when you think this read should be recv in win32 */ 1916#ifdef _WIN32
1917 WSABUF buf;
1918 DWORD recvd;
1919 buf.buf = dummy;
1920 buf.len = sizeof (dummy);
1921 WSARecv (EV_FD_TO_WIN32_HANDLE (evpipe [0]), &buf, 1, &recvd, 0, 0, 0);
1922#else
1913 read (evpipe [0], &dummy, 1); 1923 read (evpipe [0], &dummy, sizeof (dummy));
1924#endif
1914 } 1925 }
1915 } 1926 }
1916 1927
1917 pipe_write_skipped = 0; 1928 pipe_write_skipped = 0;
1918 1929
2552#if EV_FEATURE_API 2563#if EV_FEATURE_API
2553void ecb_cold 2564void ecb_cold
2554ev_verify (EV_P) EV_THROW 2565ev_verify (EV_P) EV_THROW
2555{ 2566{
2556#if EV_VERIFY 2567#if EV_VERIFY
2557 int i; 2568 int i, j;
2558 WL w; 2569 WL w, w2;
2559 2570
2560 assert (activecnt >= -1); 2571 assert (activecnt >= -1);
2561 2572
2562 assert (fdchangemax >= fdchangecnt); 2573 assert (fdchangemax >= fdchangecnt);
2563 for (i = 0; i < fdchangecnt; ++i) 2574 for (i = 0; i < fdchangecnt; ++i)
2564 assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0)); 2575 assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0));
2565 2576
2566 assert (anfdmax >= 0); 2577 assert (anfdmax >= 0);
2567 for (i = 0; i < anfdmax; ++i) 2578 for (i = j = 0; i < anfdmax; ++i)
2568 for (w = anfds [i].head; w; w = w->next) 2579 for (w = w2 = anfds [i].head; w; w = w->next)
2569 { 2580 {
2570 verify_watcher (EV_A_ (W)w); 2581 verify_watcher (EV_A_ (W)w);
2582
2583 if (j++ & 1)
2584 {
2585 assert (("libev: io watcher list contains a loop", w != w2));
2586 w2 = w2->next;
2587 }
2588
2571 assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1)); 2589 assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1));
2572 assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i)); 2590 assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i));
2573 } 2591 }
2574 2592
2575 assert (timermax >= timercnt); 2593 assert (timermax >= timercnt);
2685} 2703}
2686 2704
2687void noinline 2705void noinline
2688ev_invoke_pending (EV_P) 2706ev_invoke_pending (EV_P)
2689{ 2707{
2690 int pri; 2708 for (pendingpri = NUMPRI; pendingpri--; ) /* pendingpri is modified during the loop */
2691
2692 for (pri = NUMPRI; pri--; )
2693 while (pendingcnt [pri]) 2709 while (pendingcnt [pendingpri])
2694 { 2710 {
2695 ANPENDING *p = pendings [pri] + --pendingcnt [pri]; 2711 ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri];
2696 2712
2697 p->w->pending = 0; 2713 p->w->pending = 0;
2698 EV_CB_INVOKE (p->w, p->events); 2714 EV_CB_INVOKE (p->w, p->events);
2699 EV_FREQUENT_CHECK; 2715 EV_FREQUENT_CHECK;
2700 } 2716 }
3249 EV_FREQUENT_CHECK; 3265 EV_FREQUENT_CHECK;
3250 3266
3251 ev_start (EV_A_ (W)w, 1); 3267 ev_start (EV_A_ (W)w, 1);
3252 array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero); 3268 array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero);
3253 wlist_add (&anfds[fd].head, (WL)w); 3269 wlist_add (&anfds[fd].head, (WL)w);
3270
3271 /* common bug, apparently */
3272 assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w));
3254 3273
3255 fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY); 3274 fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
3256 w->events &= ~EV__IOFDSET; 3275 w->events &= ~EV__IOFDSET;
3257 3276
3258 EV_FREQUENT_CHECK; 3277 EV_FREQUENT_CHECK;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines