rev 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/libev/ev.c +55 -32
- data/ext/libev/ev.h +37 -26
- data/ext/libev/ev_epoll.c +30 -22
- data/ext/libev/ev_kqueue.c +30 -22
- data/ext/libev/ev_poll.c +30 -22
- data/ext/libev/ev_port.c +30 -22
- data/ext/libev/ev_select.c +30 -22
- data/ext/libev/ev_vars.h +39 -0
- data/ext/libev/ev_win32.c +31 -23
- data/ext/rev/rev.h +1 -0
- data/ext/rev/rev_loop.c +13 -0
- data/ext/rev/rev_timer_watcher.c +30 -1
- data/lib/http11_client.bundle +0 -0
- data/lib/rev.rb +2 -2
- data/lib/rev/dns_resolver.rb +1 -1
- data/lib/rev/{buffered_io.rb → io.rb} +7 -9
- data/lib/rev/loop.rb +14 -9
- data/lib/rev/socket.rb +1 -1
- data/lib/rev_ext.bundle +0 -0
- metadata +3 -3
data/ext/libev/ev.c
CHANGED
@@ -4,29 +4,37 @@
|
|
4
4
|
* Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
8
|
-
*
|
9
|
-
*
|
7
|
+
* Redistribution and use in source and binary forms, with or without modifica-
|
8
|
+
* tion, are permitted provided that the following conditions are met:
|
9
|
+
*
|
10
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
11
|
+
* this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
18
|
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
19
|
+
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
20
|
+
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
21
|
+
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
23
|
+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
24
|
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
25
|
+
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
26
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
10
27
|
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
* Alternatively, the contents of this file may be used under the terms of
|
29
|
+
* the GNU General Public License ("GPL") version 2 or any later version,
|
30
|
+
* in which case the provisions of the GPL are applicable instead of
|
31
|
+
* the above. If you wish to allow the use of your version of this file
|
32
|
+
* only under the terms of the GPL and not to allow others to use your
|
33
|
+
* version of this file under the BSD license, indicate your decision
|
34
|
+
* by deleting the provisions above and replace them with the notice
|
35
|
+
* and other provisions required by the GPL. If you do not delete the
|
36
|
+
* provisions above, a recipient may use your version of this file under
|
37
|
+
* either the BSD or the GPL.
|
30
38
|
*/
|
31
39
|
|
32
40
|
#ifdef __cplusplus
|
@@ -282,9 +290,11 @@ typedef ev_watcher *W;
|
|
282
290
|
typedef ev_watcher_list *WL;
|
283
291
|
typedef ev_watcher_time *WT;
|
284
292
|
|
293
|
+
#if EV_USE_MONOTONIC
|
285
294
|
/* sig_atomic_t is used to avoid per-thread variables or locking but still */
|
286
295
|
/* giving it a reasonably high chance of working on typical architetcures */
|
287
296
|
static sig_atomic_t have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */
|
297
|
+
#endif
|
288
298
|
|
289
299
|
#ifdef _WIN32
|
290
300
|
# include "ev_win32.c"
|
@@ -592,7 +602,11 @@ fd_reify (EV_P)
|
|
592
602
|
if (events)
|
593
603
|
{
|
594
604
|
unsigned long argp;
|
595
|
-
|
605
|
+
#ifdef EV_FD_TO_WIN32_HANDLE
|
606
|
+
anfd->handle = EV_FD_TO_WIN32_HANDLE (fd);
|
607
|
+
#else
|
608
|
+
anfd->handle = _get_osfhandle (fd);
|
609
|
+
#endif
|
596
610
|
assert (("libev only supports socket fds in this configuration", ioctlsocket (anfd->handle, FIONREAD, &argp) == 0));
|
597
611
|
}
|
598
612
|
#endif
|
@@ -855,19 +869,27 @@ static WL childs [EV_PID_HASHSIZE];
|
|
855
869
|
|
856
870
|
static ev_signal childev;
|
857
871
|
|
872
|
+
#ifndef WIFCONTINUED
|
873
|
+
# define WIFCONTINUED(status) 0
|
874
|
+
#endif
|
875
|
+
|
858
876
|
void inline_speed
|
859
877
|
child_reap (EV_P_ ev_signal *sw, int chain, int pid, int status)
|
860
878
|
{
|
861
879
|
ev_child *w;
|
880
|
+
int traced = WIFSTOPPED (status) || WIFCONTINUED (status);
|
862
881
|
|
863
882
|
for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next)
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
883
|
+
{
|
884
|
+
if ((w->pid == pid || !w->pid)
|
885
|
+
&& (!traced || (w->flags & 1)))
|
886
|
+
{
|
887
|
+
ev_set_priority (w, ev_priority (sw)); /* need to do it *now* */
|
888
|
+
w->rpid = pid;
|
889
|
+
w->rstatus = status;
|
890
|
+
ev_feed_event (EV_A_ (W)w, EV_CHILD);
|
891
|
+
}
|
892
|
+
}
|
871
893
|
}
|
872
894
|
|
873
895
|
#ifndef WCONTINUED
|
@@ -1154,6 +1176,7 @@ loop_fork (EV_P)
|
|
1154
1176
|
syserr ("(libev) error creating pipe");
|
1155
1177
|
|
1156
1178
|
siginit (EV_A);
|
1179
|
+
sigcb (EV_A_ &sigev, EV_READ);
|
1157
1180
|
}
|
1158
1181
|
|
1159
1182
|
postfork = 0;
|
@@ -1185,7 +1208,7 @@ ev_loop_destroy (EV_P)
|
|
1185
1208
|
void
|
1186
1209
|
ev_loop_fork (EV_P)
|
1187
1210
|
{
|
1188
|
-
postfork = 1;
|
1211
|
+
postfork = 1; /* must be in line with ev_default_fork */
|
1189
1212
|
}
|
1190
1213
|
|
1191
1214
|
#endif
|
@@ -1259,7 +1282,7 @@ ev_default_fork (void)
|
|
1259
1282
|
#endif
|
1260
1283
|
|
1261
1284
|
if (backend)
|
1262
|
-
postfork = 1;
|
1285
|
+
postfork = 1; /* must be in line with ev_loop_fork */
|
1263
1286
|
}
|
1264
1287
|
|
1265
1288
|
/*****************************************************************************/
|
data/ext/libev/ev.h
CHANGED
@@ -1,30 +1,40 @@
|
|
1
1
|
/*
|
2
|
+
* libev native API header
|
3
|
+
*
|
2
4
|
* Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
|
3
5
|
* All rights reserved.
|
4
6
|
*
|
5
|
-
* Redistribution and use in source and binary forms, with or without
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
7
|
+
* Redistribution and use in source and binary forms, with or without modifica-
|
8
|
+
* tion, are permitted provided that the following conditions are met:
|
9
|
+
*
|
10
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
11
|
+
* this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
18
|
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
19
|
+
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
20
|
+
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
21
|
+
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
23
|
+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
24
|
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
25
|
+
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
26
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
16
27
|
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
24
|
-
*
|
25
|
-
*
|
26
|
-
*
|
27
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
* Alternatively, the contents of this file may be used under the terms of
|
29
|
+
* the GNU General Public License ("GPL") version 2 or any later version,
|
30
|
+
* in which case the provisions of the GPL are applicable instead of
|
31
|
+
* the above. If you wish to allow the use of your version of this file
|
32
|
+
* only under the terms of the GPL and not to allow others to use your
|
33
|
+
* version of this file under the BSD license, indicate your decision
|
34
|
+
* by deleting the provisions above and replace them with the notice
|
35
|
+
* and other provisions required by the GPL. If you do not delete the
|
36
|
+
* provisions above, a recipient may use your version of this file under
|
37
|
+
* either the BSD or the GPL.
|
28
38
|
*/
|
29
39
|
|
30
40
|
#ifndef EV_H__
|
@@ -120,7 +130,7 @@ struct ev_loop;
|
|
120
130
|
# define EV_PROTOTYPES 1
|
121
131
|
#endif
|
122
132
|
|
123
|
-
#define EV_VERSION_MAJOR
|
133
|
+
#define EV_VERSION_MAJOR 3
|
124
134
|
#define EV_VERSION_MINOR 0
|
125
135
|
|
126
136
|
#ifndef EV_CB_DECLARE
|
@@ -217,6 +227,7 @@ typedef struct ev_child
|
|
217
227
|
{
|
218
228
|
EV_WATCHER_LIST (ev_child)
|
219
229
|
|
230
|
+
int flags; /* private */
|
220
231
|
int pid; /* ro */
|
221
232
|
int rpid; /* rw, holds the received pid */
|
222
233
|
int rstatus; /* rw, holds the exit status, use the macros from sys/wait.h */
|
@@ -447,7 +458,7 @@ void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revent
|
|
447
458
|
#define ev_timer_set(ev,after_,repeat_) do { (ev)->at = (after_); (ev)->repeat = (repeat_); } while (0)
|
448
459
|
#define ev_periodic_set(ev,ofs_,ival_,res_) do { (ev)->offset = (ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb= (res_); } while (0)
|
449
460
|
#define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0)
|
450
|
-
#define ev_child_set(ev,pid_)
|
461
|
+
#define ev_child_set(ev,pid_,trace_) do { (ev)->pid = (pid_); (ev)->flags = !!(trace_); } while (0)
|
451
462
|
#define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); (ev)->wd = -2; } while (0)
|
452
463
|
#define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */
|
453
464
|
#define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */
|
@@ -459,8 +470,8 @@ void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revent
|
|
459
470
|
#define ev_timer_init(ev,cb,after,repeat) do { ev_init ((ev), (cb)); ev_timer_set ((ev),(after),(repeat)); } while (0)
|
460
471
|
#define ev_periodic_init(ev,cb,at,ival,res) do { ev_init ((ev), (cb)); ev_periodic_set ((ev),(at),(ival),(res)); } while (0)
|
461
472
|
#define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0)
|
462
|
-
#define ev_child_init(ev,cb,pid)
|
463
|
-
#define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb));
|
473
|
+
#define ev_child_init(ev,cb,pid,trace) do { ev_init ((ev), (cb)); ev_child_set ((ev),(pid),(trace)); } while (0)
|
474
|
+
#define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_stat_set ((ev),(path),(interval)); } while (0)
|
464
475
|
#define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0)
|
465
476
|
#define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0)
|
466
477
|
#define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0)
|
data/ext/libev/ev_epoll.c
CHANGED
@@ -4,29 +4,37 @@
|
|
4
4
|
* Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
8
|
-
*
|
9
|
-
*
|
7
|
+
* Redistribution and use in source and binary forms, with or without modifica-
|
8
|
+
* tion, are permitted provided that the following conditions are met:
|
9
|
+
*
|
10
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
11
|
+
* this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
18
|
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
19
|
+
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
20
|
+
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
21
|
+
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
23
|
+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
24
|
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
25
|
+
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
26
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
10
27
|
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
* Alternatively, the contents of this file may be used under the terms of
|
29
|
+
* the GNU General Public License ("GPL") version 2 or any later version,
|
30
|
+
* in which case the provisions of the GPL are applicable instead of
|
31
|
+
* the above. If you wish to allow the use of your version of this file
|
32
|
+
* only under the terms of the GPL and not to allow others to use your
|
33
|
+
* version of this file under the BSD license, indicate your decision
|
34
|
+
* by deleting the provisions above and replace them with the notice
|
35
|
+
* and other provisions required by the GPL. If you do not delete the
|
36
|
+
* provisions above, a recipient may use your version of this file under
|
37
|
+
* either the BSD or the GPL.
|
30
38
|
*/
|
31
39
|
|
32
40
|
/*
|
data/ext/libev/ev_kqueue.c
CHANGED
@@ -4,29 +4,37 @@
|
|
4
4
|
* Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
8
|
-
*
|
9
|
-
*
|
7
|
+
* Redistribution and use in source and binary forms, with or without modifica-
|
8
|
+
* tion, are permitted provided that the following conditions are met:
|
9
|
+
*
|
10
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
11
|
+
* this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
18
|
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
19
|
+
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
20
|
+
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
21
|
+
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
23
|
+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
24
|
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
25
|
+
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
26
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
10
27
|
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
* Alternatively, the contents of this file may be used under the terms of
|
29
|
+
* the GNU General Public License ("GPL") version 2 or any later version,
|
30
|
+
* in which case the provisions of the GPL are applicable instead of
|
31
|
+
* the above. If you wish to allow the use of your version of this file
|
32
|
+
* only under the terms of the GPL and not to allow others to use your
|
33
|
+
* version of this file under the BSD license, indicate your decision
|
34
|
+
* by deleting the provisions above and replace them with the notice
|
35
|
+
* and other provisions required by the GPL. If you do not delete the
|
36
|
+
* provisions above, a recipient may use your version of this file under
|
37
|
+
* either the BSD or the GPL.
|
30
38
|
*/
|
31
39
|
|
32
40
|
#include <sys/types.h>
|
data/ext/libev/ev_poll.c
CHANGED
@@ -4,29 +4,37 @@
|
|
4
4
|
* Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
8
|
-
*
|
9
|
-
*
|
7
|
+
* Redistribution and use in source and binary forms, with or without modifica-
|
8
|
+
* tion, are permitted provided that the following conditions are met:
|
9
|
+
*
|
10
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
11
|
+
* this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
18
|
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
19
|
+
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
20
|
+
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
21
|
+
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
23
|
+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
24
|
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
25
|
+
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
26
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
10
27
|
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
* Alternatively, the contents of this file may be used under the terms of
|
29
|
+
* the GNU General Public License ("GPL") version 2 or any later version,
|
30
|
+
* in which case the provisions of the GPL are applicable instead of
|
31
|
+
* the above. If you wish to allow the use of your version of this file
|
32
|
+
* only under the terms of the GPL and not to allow others to use your
|
33
|
+
* version of this file under the BSD license, indicate your decision
|
34
|
+
* by deleting the provisions above and replace them with the notice
|
35
|
+
* and other provisions required by the GPL. If you do not delete the
|
36
|
+
* provisions above, a recipient may use your version of this file under
|
37
|
+
* either the BSD or the GPL.
|
30
38
|
*/
|
31
39
|
|
32
40
|
#include <poll.h>
|
data/ext/libev/ev_port.c
CHANGED
@@ -4,29 +4,37 @@
|
|
4
4
|
* Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
8
|
-
*
|
9
|
-
*
|
7
|
+
* Redistribution and use in source and binary forms, with or without modifica-
|
8
|
+
* tion, are permitted provided that the following conditions are met:
|
9
|
+
*
|
10
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
11
|
+
* this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
18
|
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
19
|
+
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
20
|
+
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
21
|
+
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
23
|
+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
24
|
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
25
|
+
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
26
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
10
27
|
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
* Alternatively, the contents of this file may be used under the terms of
|
29
|
+
* the GNU General Public License ("GPL") version 2 or any later version,
|
30
|
+
* in which case the provisions of the GPL are applicable instead of
|
31
|
+
* the above. If you wish to allow the use of your version of this file
|
32
|
+
* only under the terms of the GPL and not to allow others to use your
|
33
|
+
* version of this file under the BSD license, indicate your decision
|
34
|
+
* by deleting the provisions above and replace them with the notice
|
35
|
+
* and other provisions required by the GPL. If you do not delete the
|
36
|
+
* provisions above, a recipient may use your version of this file under
|
37
|
+
* either the BSD or the GPL.
|
30
38
|
*/
|
31
39
|
|
32
40
|
#include <sys/types.h>
|
data/ext/libev/ev_select.c
CHANGED
@@ -4,29 +4,37 @@
|
|
4
4
|
* Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
8
|
-
*
|
9
|
-
*
|
7
|
+
* Redistribution and use in source and binary forms, with or without modifica-
|
8
|
+
* tion, are permitted provided that the following conditions are met:
|
9
|
+
*
|
10
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
11
|
+
* this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
18
|
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
19
|
+
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
20
|
+
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
21
|
+
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
23
|
+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
24
|
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
25
|
+
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
26
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
10
27
|
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
* Alternatively, the contents of this file may be used under the terms of
|
29
|
+
* the GNU General Public License ("GPL") version 2 or any later version,
|
30
|
+
* in which case the provisions of the GPL are applicable instead of
|
31
|
+
* the above. If you wish to allow the use of your version of this file
|
32
|
+
* only under the terms of the GPL and not to allow others to use your
|
33
|
+
* version of this file under the BSD license, indicate your decision
|
34
|
+
* by deleting the provisions above and replace them with the notice
|
35
|
+
* and other provisions required by the GPL. If you do not delete the
|
36
|
+
* provisions above, a recipient may use your version of this file under
|
37
|
+
* either the BSD or the GPL.
|
30
38
|
*/
|
31
39
|
|
32
40
|
#ifndef _WIN32
|
data/ext/libev/ev_vars.h
CHANGED
@@ -1,3 +1,42 @@
|
|
1
|
+
/*
|
2
|
+
* loop member variable declarations
|
3
|
+
*
|
4
|
+
* Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
|
5
|
+
* All rights reserved.
|
6
|
+
*
|
7
|
+
* Redistribution and use in source and binary forms, with or without modifica-
|
8
|
+
* tion, are permitted provided that the following conditions are met:
|
9
|
+
*
|
10
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
11
|
+
* this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
18
|
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
19
|
+
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
20
|
+
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
21
|
+
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
23
|
+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
24
|
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
25
|
+
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
26
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
*
|
28
|
+
* Alternatively, the contents of this file may be used under the terms of
|
29
|
+
* the GNU General Public License ("GPL") version 2 or any later version,
|
30
|
+
* in which case the provisions of the GPL are applicable instead of
|
31
|
+
* the above. If you wish to allow the use of your version of this file
|
32
|
+
* only under the terms of the GPL and not to allow others to use your
|
33
|
+
* version of this file under the BSD license, indicate your decision
|
34
|
+
* by deleting the provisions above and replace them with the notice
|
35
|
+
* and other provisions required by the GPL. If you do not delete the
|
36
|
+
* provisions above, a recipient may use your version of this file under
|
37
|
+
* either the BSD or the GPL.
|
38
|
+
*/
|
39
|
+
|
1
40
|
#define VARx(type,name) VAR(name, type name)
|
2
41
|
|
3
42
|
VARx(ev_tstamp, now_floor) /* last time we refreshed rt_time */
|
data/ext/libev/ev_win32.c
CHANGED
@@ -1,32 +1,40 @@
|
|
1
1
|
/*
|
2
|
-
* libev win32 compatibility cruft
|
2
|
+
* libev win32 compatibility cruft (_not_ a backend)
|
3
3
|
*
|
4
4
|
* Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
|
5
5
|
* All rights reserved.
|
6
6
|
*
|
7
|
-
* Redistribution and use in source and binary forms, with or without
|
8
|
-
*
|
9
|
-
*
|
7
|
+
* Redistribution and use in source and binary forms, with or without modifica-
|
8
|
+
* tion, are permitted provided that the following conditions are met:
|
9
|
+
*
|
10
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
11
|
+
* this list of conditions and the following disclaimer.
|
12
|
+
*
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
18
|
+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
|
19
|
+
* CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
20
|
+
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
|
21
|
+
* CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
23
|
+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
24
|
+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
|
25
|
+
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
26
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
10
27
|
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
22
|
-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
23
|
-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
24
|
-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
25
|
-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
26
|
-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
27
|
-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
* Alternatively, the contents of this file may be used under the terms of
|
29
|
+
* the GNU General Public License ("GPL") version 2 or any later version,
|
30
|
+
* in which case the provisions of the GPL are applicable instead of
|
31
|
+
* the above. If you wish to allow the use of your version of this file
|
32
|
+
* only under the terms of the GPL and not to allow others to use your
|
33
|
+
* version of this file under the BSD license, indicate your decision
|
34
|
+
* by deleting the provisions above and replace them with the notice
|
35
|
+
* and other provisions required by the GPL. If you do not delete the
|
36
|
+
* provisions above, a recipient may use your version of this file under
|
37
|
+
* either the BSD or the GPL.
|
30
38
|
*/
|
31
39
|
|
32
40
|
#ifdef _WIN32
|
data/ext/rev/rev.h
CHANGED
data/ext/rev/rev_loop.c
CHANGED
@@ -56,6 +56,7 @@ static VALUE Rev_Loop_allocate(VALUE klass)
|
|
56
56
|
|
57
57
|
loop->ev_loop = 0;
|
58
58
|
|
59
|
+
loop->running = 0;
|
59
60
|
loop->events_received = 0;
|
60
61
|
loop->eventbuf_size = DEFAULT_EVENTBUF_SIZE;
|
61
62
|
loop->eventbuf = (struct Rev_Event *)xmalloc(sizeof(struct Rev_Event) * DEFAULT_EVENTBUF_SIZE);
|
@@ -177,10 +178,16 @@ static VALUE Rev_Loop_run_once(VALUE self)
|
|
177
178
|
struct Rev_Loop *loop_data;
|
178
179
|
Data_Get_Struct(self, struct Rev_Loop, loop_data);
|
179
180
|
|
181
|
+
if(loop_data->running)
|
182
|
+
rb_raise(rb_eRuntimeError, "cannot run loop from within a callback");
|
183
|
+
|
180
184
|
assert(loop_data->ev_loop && !loop_data->events_received);
|
185
|
+
|
186
|
+
loop_data->running = 1;
|
181
187
|
rb_thread_blocking_region(Rev_Loop_run_once_blocking, loop_data->ev_loop, RB_UBF_DFL, 0);
|
182
188
|
Rev_Loop_dispatch_events(loop_data);
|
183
189
|
loop_data->events_received = 0;
|
190
|
+
loop_data->running = 0;
|
184
191
|
|
185
192
|
return Qnil;
|
186
193
|
}
|
@@ -205,10 +212,16 @@ static VALUE Rev_Loop_run_nonblock(VALUE self)
|
|
205
212
|
struct Rev_Loop *loop_data;
|
206
213
|
Data_Get_Struct(self, struct Rev_Loop, loop_data);
|
207
214
|
|
215
|
+
if(loop_data->running)
|
216
|
+
rb_raise(rb_eRuntimeError, "cannot run loop from within a callback");
|
217
|
+
|
208
218
|
assert(loop_data->ev_loop && !loop_data->events_received);
|
219
|
+
|
220
|
+
loop_data->running = 1;
|
209
221
|
ev_loop(loop_data->ev_loop, EVLOOP_NONBLOCK);
|
210
222
|
Rev_Loop_dispatch_events(loop_data);
|
211
223
|
loop_data->events_received = 0;
|
224
|
+
loop_data->running = 0;
|
212
225
|
|
213
226
|
return Qnil;
|
214
227
|
}
|
data/ext/rev/rev_timer_watcher.c
CHANGED
@@ -70,6 +70,9 @@ static VALUE Rev_TimerWatcher_initialize(int argc, VALUE *argv, VALUE self)
|
|
70
70
|
rb_scan_args(argc, argv, "11", &interval, &repeating);
|
71
71
|
interval = rb_convert_type(interval, T_FLOAT, "Float", "to_f");
|
72
72
|
|
73
|
+
rb_iv_set(self, "@interval", interval);
|
74
|
+
rb_iv_set(self, "@repeating", repeating);
|
75
|
+
|
73
76
|
Data_Get_Struct(self, struct Rev_Watcher, watcher_data);
|
74
77
|
|
75
78
|
watcher_data->dispatch_callback = Rev_TimerWatcher_dispatch_callback;
|
@@ -93,7 +96,33 @@ static VALUE Rev_TimerWatcher_initialize(int argc, VALUE *argv, VALUE self)
|
|
93
96
|
*/
|
94
97
|
static VALUE Rev_TimerWatcher_attach(VALUE self, VALUE loop)
|
95
98
|
{
|
96
|
-
|
99
|
+
ev_tstamp interval, timeout;
|
100
|
+
struct Rev_Loop *loop_data;
|
101
|
+
struct Rev_Watcher *watcher_data;
|
102
|
+
|
103
|
+
if(!rb_obj_is_kind_of(loop, cRev_Loop))
|
104
|
+
rb_raise(rb_eArgError, "expected loop to be an instance of Rev::Loop");
|
105
|
+
|
106
|
+
Data_Get_Struct(loop, struct Rev_Loop, loop_data);
|
107
|
+
Data_Get_Struct(self, struct Rev_Watcher, watcher_data);
|
108
|
+
|
109
|
+
if(watcher_data->loop != Qnil)
|
110
|
+
Rev_TimerWatcher_detach(self);
|
111
|
+
|
112
|
+
watcher_data->loop = loop;
|
113
|
+
|
114
|
+
/* Calibrate timeout to account for potential drift */
|
115
|
+
interval = RFLOAT_VALUE(rb_iv_get(self, "@interval"));
|
116
|
+
timeout = interval + ev_time() - ev_now(loop_data->ev_loop);
|
117
|
+
|
118
|
+
ev_timer_set(
|
119
|
+
&watcher_data->event_types.ev_timer,
|
120
|
+
timeout,
|
121
|
+
rb_iv_get(self, "@repeating") == Qtrue ? interval : 0
|
122
|
+
);
|
123
|
+
|
124
|
+
ev_timer_start(loop_data->ev_loop, &watcher_data->event_types.ev_timer);
|
125
|
+
rb_call_super(1, &loop);
|
97
126
|
|
98
127
|
return self;
|
99
128
|
}
|
data/lib/http11_client.bundle
CHANGED
Binary file
|
data/lib/rev.rb
CHANGED
@@ -10,13 +10,13 @@ require File.dirname(__FILE__) + '/rev/watcher'
|
|
10
10
|
require File.dirname(__FILE__) + '/rev/io_watcher'
|
11
11
|
require File.dirname(__FILE__) + '/rev/timer_watcher'
|
12
12
|
require File.dirname(__FILE__) + '/rev/listener'
|
13
|
-
require File.dirname(__FILE__) + '/rev/
|
13
|
+
require File.dirname(__FILE__) + '/rev/io'
|
14
14
|
require File.dirname(__FILE__) + '/rev/dns_resolver'
|
15
15
|
require File.dirname(__FILE__) + '/rev/socket'
|
16
16
|
require File.dirname(__FILE__) + '/rev/server'
|
17
17
|
require File.dirname(__FILE__) + '/rev/http_client'
|
18
18
|
|
19
19
|
module Rev
|
20
|
-
Rev::VERSION = '0.1.
|
20
|
+
Rev::VERSION = '0.1.4' unless defined? Rev::VERSION
|
21
21
|
def self.version() VERSION end
|
22
22
|
end
|
data/lib/rev/dns_resolver.rb
CHANGED
@@ -150,7 +150,7 @@ module Rev
|
|
150
150
|
return unless rcode == 0
|
151
151
|
|
152
152
|
# Extract the question and answer counts
|
153
|
-
qdcount, ancount = message[4..7].unpack('nn').map
|
153
|
+
qdcount, ancount = message[4..7].unpack('nn').map(&:to_i)
|
154
154
|
|
155
155
|
# We only asked one question
|
156
156
|
return unless qdcount == 1
|
@@ -15,7 +15,7 @@ module Rev
|
|
15
15
|
# This class is primarily meant as a base class for other streams
|
16
16
|
# which need non-blocking writing, and is used to implement Rev's
|
17
17
|
# Socket class and its associated subclasses.
|
18
|
-
class
|
18
|
+
class IO < IOWatcher
|
19
19
|
# Maximum number of bytes to consume at once
|
20
20
|
INPUT_SIZE = 16384
|
21
21
|
|
@@ -24,7 +24,7 @@ module Rev
|
|
24
24
|
@write_buffer = Rev::Buffer.new
|
25
25
|
|
26
26
|
# Coerce the argument into an IO object if possible
|
27
|
-
@io = IO.try_convert(io)
|
27
|
+
@io = ::IO.try_convert(io)
|
28
28
|
super(@io)
|
29
29
|
end
|
30
30
|
|
@@ -58,7 +58,7 @@ module Rev
|
|
58
58
|
@write_buffer.size
|
59
59
|
end
|
60
60
|
|
61
|
-
# Close the
|
61
|
+
# Close the IO stream
|
62
62
|
def close
|
63
63
|
detach if attached?
|
64
64
|
@writer.detach if @writer and @writer.attached?
|
@@ -86,18 +86,16 @@ module Rev
|
|
86
86
|
|
87
87
|
# Attempt to write the contents of the output buffer
|
88
88
|
def write_output_buffer
|
89
|
-
return if @write_buffer.empty?
|
90
|
-
|
91
89
|
begin
|
92
90
|
@write_buffer.write_to(@io)
|
93
91
|
rescue Errno::EPIPE
|
94
92
|
return close
|
95
93
|
end
|
96
94
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
95
|
+
if @write_buffer.empty?
|
96
|
+
@writer.disable if @writer and @writer.enabled?
|
97
|
+
on_write_complete
|
98
|
+
end
|
101
99
|
end
|
102
100
|
|
103
101
|
# Inherited callback from IOWatcher
|
data/lib/rev/loop.rb
CHANGED
@@ -5,22 +5,22 @@
|
|
5
5
|
#++
|
6
6
|
|
7
7
|
require File.dirname(__FILE__) + '/../rev'
|
8
|
+
require 'thread'
|
9
|
+
|
10
|
+
# Monkeypatch Thread to include a method for obtaining the default Rev::Loop
|
11
|
+
class Thread
|
12
|
+
def _rev_loop
|
13
|
+
@_rev_loop ||= Rev::Loop.new
|
14
|
+
end
|
15
|
+
end
|
8
16
|
|
9
17
|
module Rev
|
10
18
|
class Loop
|
11
|
-
@@default_loop = {}
|
12
19
|
attr_reader :watchers
|
13
20
|
|
14
21
|
# Retrieve the default event loop for the current thread
|
15
22
|
def self.default
|
16
|
-
|
17
|
-
# are only accessible in the context of the Fiber where
|
18
|
-
# they were stored. Soo... we need to make our own
|
19
|
-
# thread-local store if we want Fiber compatibility
|
20
|
-
#
|
21
|
-
# I think this should be sufficient... but it may need
|
22
|
-
# a mutex or something, got me.
|
23
|
-
@@default_loop[Thread.current] ||= Loop.new
|
23
|
+
Thread.current._rev_loop
|
24
24
|
end
|
25
25
|
|
26
26
|
# Create a new Rev::Loop
|
@@ -98,6 +98,11 @@ module Rev
|
|
98
98
|
@running = false
|
99
99
|
end
|
100
100
|
|
101
|
+
# Does the loop have any active watchers?
|
102
|
+
def has_active_watchers?
|
103
|
+
@active_watchers > 0
|
104
|
+
end
|
105
|
+
|
101
106
|
#######
|
102
107
|
private
|
103
108
|
#######
|
data/lib/rev/socket.rb
CHANGED
data/lib/rev_ext.bundle
CHANGED
Binary file
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rev
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2008-01-
|
6
|
+
version: 0.1.4
|
7
|
+
date: 2008-01-28 00:00:00 -07:00
|
8
8
|
summary: Ruby 1.9 binding to the libev high performance event library
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -33,9 +33,9 @@ files:
|
|
33
33
|
- README
|
34
34
|
- lib/http11_client.bundle
|
35
35
|
- lib/rev
|
36
|
-
- lib/rev/buffered_io.rb
|
37
36
|
- lib/rev/dns_resolver.rb
|
38
37
|
- lib/rev/http_client.rb
|
38
|
+
- lib/rev/io.rb
|
39
39
|
- lib/rev/io_watcher.rb
|
40
40
|
- lib/rev/listener.rb
|
41
41
|
- lib/rev/loop.rb
|