… | |
… | |
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 |
… | |
… | |
1876 | write (evfd, &counter, sizeof (uint64_t)); |
1877 | write (evfd, &counter, sizeof (uint64_t)); |
1877 | } |
1878 | } |
1878 | else |
1879 | else |
1879 | #endif |
1880 | #endif |
1880 | { |
1881 | { |
1881 | /* win32 people keep sending patches that change this write() to send() */ |
1882 | #ifdef _WIN32 |
1882 | /* and then run away. but send() is wrong, it wants a socket handle on win32 */ |
1883 | WSABUF buf; |
1883 | /* so when you think this write should be a send instead, please find out */ |
1884 | DWORD sent; |
1884 | /* where your send() is from - it's definitely not the microsoft send, and */ |
1885 | buf.buf = &buf; |
1885 | /* tell me. thank you. */ |
1886 | buf.len = 1; |
1886 | /* 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); |
1887 | /* check the ev documentation on how to use this flag */ |
1888 | #else |
1888 | write (evpipe [1], &(evpipe [1]), 1); |
1889 | write (evpipe [1], &(evpipe [1]), 1); |
|
|
1890 | #endif |
1889 | } |
1891 | } |
1890 | |
1892 | |
1891 | errno = old_errno; |
1893 | errno = old_errno; |
1892 | } |
1894 | } |
1893 | } |
1895 | } |
… | |
… | |
1908 | read (evfd, &counter, sizeof (uint64_t)); |
1910 | read (evfd, &counter, sizeof (uint64_t)); |
1909 | } |
1911 | } |
1910 | else |
1912 | else |
1911 | #endif |
1913 | #endif |
1912 | { |
1914 | { |
1913 | char dummy; |
1915 | char dummy[4]; |
1914 | /* 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 |
1915 | read (evpipe [0], &dummy, 1); |
1923 | read (evpipe [0], &dummy, sizeof (dummy)); |
|
|
1924 | #endif |
1916 | } |
1925 | } |
1917 | } |
1926 | } |
1918 | |
1927 | |
1919 | pipe_write_skipped = 0; |
1928 | pipe_write_skipped = 0; |
1920 | |
1929 | |
… | |
… | |
2555 | void ecb_cold |
2564 | void ecb_cold |
2556 | ev_verify (EV_P) EV_THROW |
2565 | ev_verify (EV_P) EV_THROW |
2557 | { |
2566 | { |
2558 | #if EV_VERIFY |
2567 | #if EV_VERIFY |
2559 | int i; |
2568 | int i; |
2560 | WL w; |
2569 | WL w, w2; |
2561 | |
2570 | |
2562 | assert (activecnt >= -1); |
2571 | assert (activecnt >= -1); |
2563 | |
2572 | |
2564 | assert (fdchangemax >= fdchangecnt); |
2573 | assert (fdchangemax >= fdchangecnt); |
2565 | for (i = 0; i < fdchangecnt; ++i) |
2574 | for (i = 0; i < fdchangecnt; ++i) |
2566 | assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0)); |
2575 | assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0)); |
2567 | |
2576 | |
2568 | assert (anfdmax >= 0); |
2577 | assert (anfdmax >= 0); |
2569 | for (i = 0; i < anfdmax; ++i) |
2578 | for (i = 0; i < anfdmax; ++i) |
|
|
2579 | { |
|
|
2580 | int j = 0; |
|
|
2581 | |
2570 | for (w = anfds [i].head; w; w = w->next) |
2582 | for (w = w2 = anfds [i].head; w; w = w->next) |
2571 | { |
2583 | { |
2572 | verify_watcher (EV_A_ (W)w); |
2584 | verify_watcher (EV_A_ (W)w); |
|
|
2585 | |
|
|
2586 | if (j++ & 1) |
|
|
2587 | { |
|
|
2588 | assert (("libev: io watcher list contains a loop", w != w2)); |
|
|
2589 | w2 = w2->next; |
|
|
2590 | } |
|
|
2591 | |
2573 | assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1)); |
2592 | assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1)); |
2574 | assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i)); |
2593 | assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i)); |
2575 | } |
2594 | } |
|
|
2595 | } |
2576 | |
2596 | |
2577 | assert (timermax >= timercnt); |
2597 | assert (timermax >= timercnt); |
2578 | verify_heap (EV_A_ timers, timercnt); |
2598 | verify_heap (EV_A_ timers, timercnt); |
2579 | |
2599 | |
2580 | #if EV_PERIODIC_ENABLE |
2600 | #if EV_PERIODIC_ENABLE |
… | |
… | |
3249 | EV_FREQUENT_CHECK; |
3269 | EV_FREQUENT_CHECK; |
3250 | |
3270 | |
3251 | ev_start (EV_A_ (W)w, 1); |
3271 | ev_start (EV_A_ (W)w, 1); |
3252 | array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero); |
3272 | array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero); |
3253 | wlist_add (&anfds[fd].head, (WL)w); |
3273 | wlist_add (&anfds[fd].head, (WL)w); |
|
|
3274 | |
|
|
3275 | /* common bug, apparently */ |
|
|
3276 | assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w)); |
3254 | |
3277 | |
3255 | fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY); |
3278 | fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY); |
3256 | w->events &= ~EV__IOFDSET; |
3279 | w->events &= ~EV__IOFDSET; |
3257 | |
3280 | |
3258 | EV_FREQUENT_CHECK; |
3281 | EV_FREQUENT_CHECK; |