rev 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +20 -0
- data/{README → README.textile} +30 -63
- data/Rakefile +3 -3
- data/ext/libev/Changes +64 -1
- data/ext/libev/LICENSE +1 -1
- data/ext/libev/ev.c +741 -263
- data/ext/libev/ev.h +108 -53
- data/ext/libev/ev_epoll.c +14 -3
- data/ext/libev/ev_kqueue.c +3 -1
- data/ext/libev/ev_poll.c +6 -2
- data/ext/libev/ev_port.c +3 -1
- data/ext/libev/ev_select.c +10 -2
- data/ext/libev/ev_vars.h +34 -11
- data/ext/libev/ev_win32.c +13 -14
- data/ext/libev/ev_wrap.h +44 -16
- data/ext/rev/extconf.rb +5 -5
- data/ext/rev/rev.h +1 -0
- data/ext/rev/rev_ext.c +1 -3
- data/ext/rev/rev_io_watcher.c +0 -2
- data/ext/rev/rev_stat_watcher.c +182 -0
- data/lib/rev.rb +11 -12
- data/lib/rev/dns_resolver.rb +6 -6
- data/lib/rev/http_client.rb +1 -1
- data/lib/rev/io.rb +1 -1
- data/lib/rev/listener.rb +19 -4
- data/lib/rev/server.rb +18 -3
- data/lib/rev/socket.rb +1 -1
- data/lib/rev/ssl.rb +6 -1
- data/lib/revem.rb +16 -1
- data/rev.gemspec +7 -4
- metadata +21 -14
- data/ext/rev/rev_buffer.c +0 -629
data/ext/libev/ev.h
CHANGED
@@ -37,8 +37,8 @@
|
|
37
37
|
* either the BSD or the GPL.
|
38
38
|
*/
|
39
39
|
|
40
|
-
#ifndef
|
41
|
-
#define
|
40
|
+
#ifndef EV_H_
|
41
|
+
#define EV_H_
|
42
42
|
|
43
43
|
#ifdef __cplusplus
|
44
44
|
extern "C" {
|
@@ -82,6 +82,10 @@ typedef double ev_tstamp;
|
|
82
82
|
# define EV_ASYNC_ENABLE 1
|
83
83
|
#endif
|
84
84
|
|
85
|
+
#ifndef EV_WALK_ENABLE
|
86
|
+
# define EV_WALK_ENABLE 0 /* not yet */
|
87
|
+
#endif
|
88
|
+
|
85
89
|
#ifndef EV_ATOMIC_T
|
86
90
|
# include <signal.h>
|
87
91
|
# define EV_ATOMIC_T sig_atomic_t volatile
|
@@ -133,8 +137,10 @@ struct ev_loop;
|
|
133
137
|
#define EV_NONE 0x00 /* no events */
|
134
138
|
#define EV_READ 0x01 /* ev_io detected read will not block */
|
135
139
|
#define EV_WRITE 0x02 /* ev_io detected write will not block */
|
136
|
-
#define
|
140
|
+
#define EV__IOFDSET 0x80 /* internal use only */
|
141
|
+
#define EV_IO EV_READ /* alias for type-detection */
|
137
142
|
#define EV_TIMEOUT 0x00000100 /* timer timed out */
|
143
|
+
#define EV_TIMER EV_TIMEOUT /* alias for type-detection */
|
138
144
|
#define EV_PERIODIC 0x00000200 /* periodic timer timed out */
|
139
145
|
#define EV_SIGNAL 0x00000400 /* signal was received */
|
140
146
|
#define EV_CHILD 0x00000800 /* child/pid had status change */
|
@@ -145,6 +151,7 @@ struct ev_loop;
|
|
145
151
|
#define EV_EMBED 0x00010000 /* embedded event loop needs sweep */
|
146
152
|
#define EV_FORK 0x00020000 /* event loop resumed in child */
|
147
153
|
#define EV_ASYNC 0x00040000 /* async intra-loop signal */
|
154
|
+
#define EV_CUSTOM 0x01000000 /* for use by user code */
|
148
155
|
#define EV_ERROR 0x80000000 /* sent when an error occurs */
|
149
156
|
|
150
157
|
/* can be used to add custom fields to all watchers, while losing binary compatibility */
|
@@ -156,7 +163,7 @@ struct ev_loop;
|
|
156
163
|
#endif
|
157
164
|
|
158
165
|
#define EV_VERSION_MAJOR 3
|
159
|
-
#define EV_VERSION_MINOR
|
166
|
+
#define EV_VERSION_MINOR 8
|
160
167
|
|
161
168
|
#ifndef EV_CB_DECLARE
|
162
169
|
# define EV_CB_DECLARE(type) void (*cb)(EV_P_ struct type *w, int revents);
|
@@ -182,11 +189,17 @@ struct ev_loop;
|
|
182
189
|
* or the array index + 1 in the pendings array.
|
183
190
|
*/
|
184
191
|
|
192
|
+
#if EV_MINPRI == EV_MAXPRI
|
193
|
+
# define EV_DECL_PRIORITY
|
194
|
+
#else
|
195
|
+
# define EV_DECL_PRIORITY int priority;
|
196
|
+
#endif
|
197
|
+
|
185
198
|
/* shared by all watchers */
|
186
199
|
#define EV_WATCHER(type) \
|
187
200
|
int active; /* private */ \
|
188
201
|
int pending; /* private */ \
|
189
|
-
|
202
|
+
EV_DECL_PRIORITY /* private */ \
|
190
203
|
EV_COMMON /* rw */ \
|
191
204
|
EV_CB_DECLARE (type) /* private */
|
192
205
|
|
@@ -391,6 +404,9 @@ union ev_any_watcher
|
|
391
404
|
/* flag bits */
|
392
405
|
#define EVFLAG_NOENV 0x01000000U /* do NOT consult environment */
|
393
406
|
#define EVFLAG_FORKCHECK 0x02000000U /* check for a fork in each iteration */
|
407
|
+
/* debugging/feature disable */
|
408
|
+
#define EVFLAG_NOINOTIFY 0x00100000U /* do not attempt to use inotify */
|
409
|
+
#define EVFLAG_NOSIGFD 0x00200000U /* do not attempt to use signalfd */
|
394
410
|
/* method bits to be ored together */
|
395
411
|
#define EVBACKEND_SELECT 0x00000001U /* about anywhere */
|
396
412
|
#define EVBACKEND_POLL 0x00000002U /* !win */
|
@@ -454,10 +470,8 @@ ev_default_loop (unsigned int flags)
|
|
454
470
|
struct ev_loop *ev_loop_new (unsigned int flags);
|
455
471
|
void ev_loop_destroy (EV_P);
|
456
472
|
void ev_loop_fork (EV_P);
|
457
|
-
void ev_loop_verify (EV_P);
|
458
473
|
|
459
474
|
ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */
|
460
|
-
void ev_now_update (EV_P);
|
461
475
|
|
462
476
|
#else
|
463
477
|
|
@@ -491,8 +505,17 @@ void ev_default_destroy (void); /* destroy the default loop */
|
|
491
505
|
/* you can actually call it at any time, anywhere :) */
|
492
506
|
void ev_default_fork (void);
|
493
507
|
|
494
|
-
unsigned int ev_backend (EV_P);
|
495
|
-
|
508
|
+
unsigned int ev_backend (EV_P); /* backend in use by loop */
|
509
|
+
|
510
|
+
void ev_now_update (EV_P); /* update event loop time */
|
511
|
+
|
512
|
+
#if EV_WALK_ENABLE
|
513
|
+
/* walk (almost) all watchers in the loop of a given type, invoking the */
|
514
|
+
/* callback on every such watcher. The callback might stop the watcher, */
|
515
|
+
/* but do nothing else with the loop */
|
516
|
+
void ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w));
|
517
|
+
#endif
|
518
|
+
|
496
519
|
#endif /* prototypes */
|
497
520
|
|
498
521
|
#define EVLOOP_NONBLOCK 1 /* do not block/wait */
|
@@ -505,68 +528,98 @@ unsigned int ev_loop_count (EV_P); /* number of loop iterations */
|
|
505
528
|
void ev_loop (EV_P_ int flags);
|
506
529
|
void ev_unloop (EV_P_ int how); /* set to 1 to break out of event loop, set to 2 to break out of all event loops */
|
507
530
|
|
508
|
-
void ev_set_io_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */
|
509
|
-
void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */
|
510
|
-
|
511
531
|
/*
|
512
532
|
* ref/unref can be used to add or remove a refcount on the mainloop. every watcher
|
513
|
-
* keeps one reference. if you have a long-
|
533
|
+
* keeps one reference. if you have a long-running watcher you never unregister that
|
514
534
|
* should not keep ev_loop from running, unref() after starting, and ref() before stopping.
|
515
535
|
*/
|
516
536
|
void ev_ref (EV_P);
|
517
537
|
void ev_unref (EV_P);
|
518
538
|
|
519
|
-
/*
|
520
|
-
|
539
|
+
/*
|
540
|
+
* convenience function, wait for a single event, without registering an event watcher
|
541
|
+
* if timeout is < 0, do wait indefinitely
|
542
|
+
*/
|
521
543
|
void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg);
|
544
|
+
|
545
|
+
# if EV_MINIMAL < 2
|
546
|
+
unsigned int ev_loop_count (EV_P); /* number of loop iterations */
|
547
|
+
unsigned int ev_loop_depth (EV_P); /* #ev_loop enters - #ev_loop leaves */
|
548
|
+
void ev_loop_verify (EV_P); /* abort if loop data corrupted */
|
549
|
+
|
550
|
+
void ev_set_io_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */
|
551
|
+
void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */
|
552
|
+
|
553
|
+
/* advanced stuff for threading etc. support, see docs */
|
554
|
+
void ev_set_userdata (EV_P_ void *data);
|
555
|
+
void *ev_userdata (EV_P);
|
556
|
+
void ev_set_invoke_pending_cb (EV_P_ void (*invoke_pending_cb)(EV_P));
|
557
|
+
void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P), void (*acquire)(EV_P));
|
558
|
+
|
559
|
+
unsigned int ev_pending_count (EV_P); /* number of pending events, if any */
|
560
|
+
void ev_invoke_pending (EV_P); /* invoke all pending watchers */
|
561
|
+
|
562
|
+
/*
|
563
|
+
* stop/start the timer handling.
|
564
|
+
*/
|
565
|
+
void ev_suspend (EV_P);
|
566
|
+
void ev_resume (EV_P);
|
567
|
+
#endif
|
568
|
+
|
522
569
|
#endif
|
523
570
|
|
524
571
|
/* these may evaluate ev multiple times, and the other arguments at most once */
|
525
572
|
/* either use ev_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */
|
526
573
|
#define ev_init(ev,cb_) do { \
|
527
|
-
((ev_watcher *)(void *)(ev))->active
|
528
|
-
((ev_watcher *)(void *)(ev))->pending
|
529
|
-
|
574
|
+
((ev_watcher *)(void *)(ev))->active = \
|
575
|
+
((ev_watcher *)(void *)(ev))->pending = 0; \
|
576
|
+
ev_set_priority ((ev), 0); \
|
530
577
|
ev_set_cb ((ev), cb_); \
|
531
578
|
} while (0)
|
532
579
|
|
533
|
-
#define ev_io_set(ev,fd_,events_)
|
534
|
-
#define ev_timer_set(ev,after_,repeat_)
|
535
|
-
#define ev_periodic_set(ev,ofs_,ival_,
|
536
|
-
#define ev_signal_set(ev,signum_)
|
537
|
-
#define ev_child_set(ev,pid_,trace_)
|
538
|
-
#define ev_stat_set(ev,path_,interval_)
|
539
|
-
#define ev_idle_set(ev)
|
540
|
-
#define ev_prepare_set(ev)
|
541
|
-
#define ev_check_set(ev)
|
542
|
-
#define ev_embed_set(ev,other_)
|
543
|
-
#define ev_fork_set(ev)
|
544
|
-
#define ev_async_set(ev)
|
545
|
-
|
546
|
-
#define ev_io_init(ev,cb,fd,events)
|
547
|
-
#define ev_timer_init(ev,cb,after,repeat)
|
548
|
-
#define ev_periodic_init(ev,cb,
|
549
|
-
#define ev_signal_init(ev,cb,signum)
|
550
|
-
#define ev_child_init(ev,cb,pid,trace)
|
551
|
-
#define ev_stat_init(ev,cb,path,interval)
|
552
|
-
#define ev_idle_init(ev,cb)
|
553
|
-
#define ev_prepare_init(ev,cb)
|
554
|
-
#define ev_check_init(ev,cb)
|
555
|
-
#define ev_embed_init(ev,cb,other)
|
556
|
-
#define ev_fork_init(ev,cb)
|
557
|
-
#define ev_async_init(ev,cb)
|
558
|
-
|
559
|
-
#define ev_is_pending(ev)
|
560
|
-
#define ev_is_active(ev)
|
561
|
-
|
562
|
-
#define
|
563
|
-
|
564
|
-
#
|
565
|
-
|
566
|
-
#define
|
580
|
+
#define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_) | EV__IOFDSET; } while (0)
|
581
|
+
#define ev_timer_set(ev,after_,repeat_) do { ((ev_watcher_time *)(ev))->at = (after_); (ev)->repeat = (repeat_); } while (0)
|
582
|
+
#define ev_periodic_set(ev,ofs_,ival_,rcb_) do { (ev)->offset = (ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb = (rcb_); } while (0)
|
583
|
+
#define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0)
|
584
|
+
#define ev_child_set(ev,pid_,trace_) do { (ev)->pid = (pid_); (ev)->flags = !!(trace_); } while (0)
|
585
|
+
#define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); (ev)->wd = -2; } while (0)
|
586
|
+
#define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */
|
587
|
+
#define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */
|
588
|
+
#define ev_check_set(ev) /* nop, yes, this is a serious in-joke */
|
589
|
+
#define ev_embed_set(ev,other_) do { (ev)->other = (other_); } while (0)
|
590
|
+
#define ev_fork_set(ev) /* nop, yes, this is a serious in-joke */
|
591
|
+
#define ev_async_set(ev) do { (ev)->sent = 0; } while (0)
|
592
|
+
|
593
|
+
#define ev_io_init(ev,cb,fd,events) do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0)
|
594
|
+
#define ev_timer_init(ev,cb,after,repeat) do { ev_init ((ev), (cb)); ev_timer_set ((ev),(after),(repeat)); } while (0)
|
595
|
+
#define ev_periodic_init(ev,cb,ofs,ival,rcb) do { ev_init ((ev), (cb)); ev_periodic_set ((ev),(ofs),(ival),(rcb)); } while (0)
|
596
|
+
#define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0)
|
597
|
+
#define ev_child_init(ev,cb,pid,trace) do { ev_init ((ev), (cb)); ev_child_set ((ev),(pid),(trace)); } while (0)
|
598
|
+
#define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_stat_set ((ev),(path),(interval)); } while (0)
|
599
|
+
#define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0)
|
600
|
+
#define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0)
|
601
|
+
#define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0)
|
602
|
+
#define ev_embed_init(ev,cb,other) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(other)); } while (0)
|
603
|
+
#define ev_fork_init(ev,cb) do { ev_init ((ev), (cb)); ev_fork_set ((ev)); } while (0)
|
604
|
+
#define ev_async_init(ev,cb) do { ev_init ((ev), (cb)); ev_async_set ((ev)); } while (0)
|
605
|
+
|
606
|
+
#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */
|
607
|
+
#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */
|
608
|
+
|
609
|
+
#define ev_cb(ev) (ev)->cb /* rw */
|
610
|
+
|
611
|
+
#if EV_MINPRI == EV_MAXPRI
|
612
|
+
# define ev_priority(ev) ((ev), EV_MINPRI)
|
613
|
+
# define ev_set_priority(ev,pri) ((ev), (pri))
|
614
|
+
#else
|
615
|
+
# define ev_priority(ev) ((((ev_watcher *)(void *)(ev))->priority) + 0)
|
616
|
+
# define ev_set_priority(ev,pri) ( (ev_watcher *)(void *)(ev))->priority = (pri)
|
617
|
+
#endif
|
618
|
+
|
619
|
+
#define ev_periodic_at(ev) (((ev_watcher_time *)(ev))->at + 0.)
|
567
620
|
|
568
621
|
#ifndef ev_set_cb
|
569
|
-
# define ev_set_cb(ev,cb_)
|
622
|
+
# define ev_set_cb(ev,cb_) ev_cb (ev) = (cb_)
|
570
623
|
#endif
|
571
624
|
|
572
625
|
/* stopping (enabling, adding) a watcher does nothing if it is already running */
|
@@ -588,6 +641,8 @@ void ev_timer_start (EV_P_ ev_timer *w);
|
|
588
641
|
void ev_timer_stop (EV_P_ ev_timer *w);
|
589
642
|
/* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */
|
590
643
|
void ev_timer_again (EV_P_ ev_timer *w);
|
644
|
+
/* return remaining time */
|
645
|
+
ev_tstamp ev_timer_remaining (EV_P_ ev_timer *w);
|
591
646
|
|
592
647
|
#if EV_PERIODIC_ENABLE
|
593
648
|
void ev_periodic_start (EV_P_ ev_periodic *w);
|
data/ext/libev/ev_epoll.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libev epoll fd activity backend
|
3
3
|
*
|
4
|
-
* Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de>
|
4
|
+
* Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
7
|
* Redistribution and use in source and binary forms, with or without modifica-
|
@@ -119,7 +119,13 @@ static void
|
|
119
119
|
epoll_poll (EV_P_ ev_tstamp timeout)
|
120
120
|
{
|
121
121
|
int i;
|
122
|
-
int eventcnt
|
122
|
+
int eventcnt;
|
123
|
+
|
124
|
+
/* epoll wait times cannot be larger than (LONG_MAX - 999UL) / HZ msecs, which is below */
|
125
|
+
/* the default libev max wait time, however. */
|
126
|
+
EV_RELEASE_CB;
|
127
|
+
eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, (int)ceil (timeout * 1000.));
|
128
|
+
EV_ACQUIRE_CB;
|
123
129
|
|
124
130
|
if (expect_false (eventcnt < 0))
|
125
131
|
{
|
@@ -177,7 +183,12 @@ epoll_poll (EV_P_ ev_tstamp timeout)
|
|
177
183
|
int inline_size
|
178
184
|
epoll_init (EV_P_ int flags)
|
179
185
|
{
|
180
|
-
|
186
|
+
#ifdef EPOLL_CLOEXEC
|
187
|
+
backend_fd = epoll_create1 (EPOLL_CLOEXEC);
|
188
|
+
|
189
|
+
if (backend_fd <= 0)
|
190
|
+
#endif
|
191
|
+
backend_fd = epoll_create (256);
|
181
192
|
|
182
193
|
if (backend_fd < 0)
|
183
194
|
return 0;
|
data/ext/libev/ev_kqueue.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libev kqueue backend
|
3
3
|
*
|
4
|
-
* Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de>
|
4
|
+
* Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
7
|
* Redistribution and use in source and binary forms, with or without modifica-
|
@@ -93,9 +93,11 @@ kqueue_poll (EV_P_ ev_tstamp timeout)
|
|
93
93
|
kqueue_events = (struct kevent *)ev_malloc (sizeof (struct kevent) * kqueue_eventmax);
|
94
94
|
}
|
95
95
|
|
96
|
+
EV_RELEASE_CB;
|
96
97
|
ts.tv_sec = (time_t)timeout;
|
97
98
|
ts.tv_nsec = (long)((timeout - (ev_tstamp)ts.tv_sec) * 1e9);
|
98
99
|
res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts);
|
100
|
+
EV_ACQUIRE_CB;
|
99
101
|
kqueue_changecnt = 0;
|
100
102
|
|
101
103
|
if (expect_false (res < 0))
|
data/ext/libev/ev_poll.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libev poll fd activity backend
|
3
3
|
*
|
4
|
-
* Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de>
|
4
|
+
* Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
7
|
* Redistribution and use in source and binary forms, with or without modifica-
|
@@ -89,7 +89,11 @@ static void
|
|
89
89
|
poll_poll (EV_P_ ev_tstamp timeout)
|
90
90
|
{
|
91
91
|
struct pollfd *p;
|
92
|
-
int res
|
92
|
+
int res;
|
93
|
+
|
94
|
+
EV_RELEASE_CB;
|
95
|
+
res = poll (polls, pollcnt, (int)ceil (timeout * 1000.));
|
96
|
+
EV_ACQUIRE_CB;
|
93
97
|
|
94
98
|
if (expect_false (res < 0))
|
95
99
|
{
|
data/ext/libev/ev_port.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libev solaris event port backend
|
3
3
|
*
|
4
|
-
* Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de>
|
4
|
+
* Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
7
|
* Redistribution and use in source and binary forms, with or without modifica-
|
@@ -85,9 +85,11 @@ port_poll (EV_P_ ev_tstamp timeout)
|
|
85
85
|
struct timespec ts;
|
86
86
|
uint_t nget = 1;
|
87
87
|
|
88
|
+
EV_RELEASE_CB;
|
88
89
|
ts.tv_sec = (time_t)timeout;
|
89
90
|
ts.tv_nsec = (long)(timeout - (ev_tstamp)ts.tv_sec) * 1e9;
|
90
91
|
res = port_getn (backend_fd, port_events, port_eventmax, &nget, &ts);
|
92
|
+
EV_ACQUIRE_CB;
|
91
93
|
|
92
94
|
if (res == -1)
|
93
95
|
{
|
data/ext/libev/ev_select.c
CHANGED
@@ -140,6 +140,7 @@ select_poll (EV_P_ ev_tstamp timeout)
|
|
140
140
|
int res;
|
141
141
|
int fd_setsize;
|
142
142
|
|
143
|
+
EV_RELEASE_CB;
|
143
144
|
tv.tv_sec = (long)timeout;
|
144
145
|
tv.tv_usec = (long)((timeout - (ev_tstamp)tv.tv_sec) * 1e6);
|
145
146
|
|
@@ -166,6 +167,7 @@ select_poll (EV_P_ ev_tstamp timeout)
|
|
166
167
|
#else
|
167
168
|
res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv);
|
168
169
|
#endif
|
170
|
+
EV_ACQUIRE_CB;
|
169
171
|
|
170
172
|
if (expect_false (res < 0))
|
171
173
|
{
|
@@ -280,9 +282,12 @@ select_init (EV_P_ int flags)
|
|
280
282
|
#else
|
281
283
|
vec_max = 0;
|
282
284
|
vec_ri = 0;
|
283
|
-
|
284
|
-
|
285
|
+
vec_ro = 0;
|
286
|
+
vec_wi = 0;
|
285
287
|
vec_wo = 0;
|
288
|
+
#ifdef _WIN32
|
289
|
+
vec_eo = 0;
|
290
|
+
#endif
|
286
291
|
#endif
|
287
292
|
|
288
293
|
return EVBACKEND_SELECT;
|
@@ -295,6 +300,9 @@ select_destroy (EV_P)
|
|
295
300
|
ev_free (vec_ro);
|
296
301
|
ev_free (vec_wi);
|
297
302
|
ev_free (vec_wo);
|
303
|
+
#ifdef _WIN32
|
304
|
+
ev_free (vec_eo);
|
305
|
+
#endif
|
298
306
|
}
|
299
307
|
|
300
308
|
|
data/ext/libev/ev_vars.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* loop member variable declarations
|
3
3
|
*
|
4
|
-
* Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de>
|
4
|
+
* Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
7
|
* Redistribution and use in source and binary forms, with or without modifica-
|
@@ -48,18 +48,31 @@ VARx(ev_tstamp, timeout_blocktime)
|
|
48
48
|
|
49
49
|
VARx(int, backend)
|
50
50
|
VARx(int, activecnt) /* total number of active events ("refcount") */
|
51
|
-
VARx(unsigned
|
51
|
+
VARx(unsigned char, loop_done) /* signal by ev_unloop */
|
52
52
|
|
53
53
|
VARx(int, backend_fd)
|
54
54
|
VARx(ev_tstamp, backend_fudge) /* assumed typical timer resolution */
|
55
55
|
VAR (backend_modify, void (*backend_modify)(EV_P_ int fd, int oev, int nev))
|
56
56
|
VAR (backend_poll , void (*backend_poll)(EV_P_ ev_tstamp timeout))
|
57
57
|
|
58
|
+
VARx(ANFD *, anfds)
|
59
|
+
VARx(int, anfdmax)
|
60
|
+
|
61
|
+
VAR (pendings, ANPENDING *pendings [NUMPRI])
|
62
|
+
VAR (pendingmax, int pendingmax [NUMPRI])
|
63
|
+
VAR (pendingcnt, int pendingcnt [NUMPRI])
|
64
|
+
VARx(ev_prepare, pending_w) /* dummy pending watcher */
|
65
|
+
|
66
|
+
/* for reverse feeding of events */
|
67
|
+
VARx(W *, rfeeds)
|
68
|
+
VARx(int, rfeedmax)
|
69
|
+
VARx(int, rfeedcnt)
|
70
|
+
|
58
71
|
#if EV_USE_EVENTFD || EV_GENWRAP
|
59
72
|
VARx(int, evfd)
|
60
73
|
#endif
|
61
74
|
VAR (evpipe, int evpipe [2])
|
62
|
-
VARx(ev_io,
|
75
|
+
VARx(ev_io, pipe_w)
|
63
76
|
|
64
77
|
#if !defined(_WIN32) || EV_GENWRAP
|
65
78
|
VARx(pid_t, curpid)
|
@@ -104,13 +117,6 @@ VARx(struct port_event *, port_events)
|
|
104
117
|
VARx(int, port_eventmax)
|
105
118
|
#endif
|
106
119
|
|
107
|
-
VARx(ANFD *, anfds)
|
108
|
-
VARx(int, anfdmax)
|
109
|
-
|
110
|
-
VAR (pendings, ANPENDING *pendings [NUMPRI])
|
111
|
-
VAR (pendingmax, int pendingmax [NUMPRI])
|
112
|
-
VAR (pendingcnt, int pendingcnt [NUMPRI])
|
113
|
-
|
114
120
|
VARx(int *, fdchanges)
|
115
121
|
VARx(int, fdchangemax)
|
116
122
|
VARx(int, fdchangecnt)
|
@@ -146,8 +152,8 @@ VARx(int, forkmax)
|
|
146
152
|
VARx(int, forkcnt)
|
147
153
|
#endif
|
148
154
|
|
149
|
-
VARx(EV_ATOMIC_T, gotasync)
|
150
155
|
#if EV_ASYNC_ENABLE || EV_GENWRAP
|
156
|
+
VARx(EV_ATOMIC_T, async_pending)
|
151
157
|
VARx(struct ev_async **, asyncs)
|
152
158
|
VARx(int, asyncmax)
|
153
159
|
VARx(int, asynccnt)
|
@@ -160,5 +166,22 @@ VARx(char, fs_2625) /* whether we are running in linux 2.6.25 or newer */
|
|
160
166
|
VAR (fs_hash, ANFS fs_hash [EV_INOTIFY_HASHSIZE])
|
161
167
|
#endif
|
162
168
|
|
169
|
+
VARx(EV_ATOMIC_T, sig_pending)
|
170
|
+
#if EV_USE_SIGNALFD || EV_GENWRAP
|
171
|
+
VARx(int, sigfd)
|
172
|
+
VARx(ev_io, sigfd_w)
|
173
|
+
VARx(sigset_t, sigfd_set)
|
174
|
+
#endif
|
175
|
+
|
176
|
+
#if EV_MINIMAL < 2 || EV_GENWRAP
|
177
|
+
VARx(unsigned int, loop_count) /* total number of loop iterations/blocks */
|
178
|
+
VARx(unsigned int, loop_depth) /* #ev_loop enters - #ev_loop leaves */
|
179
|
+
|
180
|
+
VARx(void *, userdata)
|
181
|
+
VAR (release_cb, void (*release_cb)(EV_P))
|
182
|
+
VAR (acquire_cb, void (*acquire_cb)(EV_P))
|
183
|
+
VAR (invoke_cb , void (*invoke_cb) (EV_P))
|
184
|
+
#endif
|
185
|
+
|
163
186
|
#undef VARx
|
164
187
|
|