sleepy_penguin 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.manifest +1 -0
- data/ChangeLog +36 -0
- data/GIT-VERSION-FILE +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/LATEST +13 -5
- data/NEWS +16 -0
- data/ext/sleepy_penguin/epoll.c +8 -0
- data/lib/sleepy_penguin.rb +2 -2
- data/test/test_epoll_gc.rb +47 -0
- metadata +7 -5
data/.manifest
CHANGED
data/ChangeLog
CHANGED
@@ -1,5 +1,41 @@
|
|
1
1
|
ChangeLog from http://git.bogomips.org/cgit/sleepy_penguin.git
|
2
2
|
|
3
|
+
commit 743560f8af768a65e6f286fecf80b6ebd91be812
|
4
|
+
Author: Eric Wong <e@yhbt.net>
|
5
|
+
Date: Sat Jan 15 11:54:15 2011 +0000
|
6
|
+
|
7
|
+
sleepy_penguin 1.2.0 - epoll GC help
|
8
|
+
|
9
|
+
One convenience fix:
|
10
|
+
|
11
|
+
epoll: prevent IO objects from getting GC-ed
|
12
|
+
|
13
|
+
Users of our code may forget to keep references for their IO
|
14
|
+
objects at all, and since it's not possible for GC to mark
|
15
|
+
kernel memory, we just hold on to the IO objects for them.
|
16
|
+
|
17
|
+
We can't unmark close()d file descriptors, ever, so we don't
|
18
|
+
bother with the EPOLL_CTL_DEL case, either. Just storing IO
|
19
|
+
objects in an array using the raw descriptor as a key will allow
|
20
|
+
bounded space usage just like the in-kernel FD tables as long
|
21
|
+
as the user remembers to close descriptors themselves.
|
22
|
+
|
23
|
+
commit 681c7b02f1e1d9ca70a5748ef986361840746c3d
|
24
|
+
Author: Eric Wong <e@yhbt.net>
|
25
|
+
Date: Sat Jan 15 11:46:13 2011 +0000
|
26
|
+
|
27
|
+
epoll: prevent IO objects from getting GC-ed
|
28
|
+
|
29
|
+
Users of our code may forget to keep references for their IO
|
30
|
+
objects at all, and since it's not possible for GC to mark
|
31
|
+
kernel memory, we just hold on to the IO objects for them.
|
32
|
+
|
33
|
+
We can't unmark close()d file descriptors, ever, so we don't
|
34
|
+
bother with the EPOLL_CTL_DEL case, either. Just storing IO
|
35
|
+
objects in an array using the raw descriptor as a key will allow
|
36
|
+
bounded space usage just like the in-kernel FD tables as long
|
37
|
+
as the user remembers to close descriptors themselves.
|
38
|
+
|
3
39
|
commit ab4f1a27e5d2c1688a33870b6d070aaa510ccdbc
|
4
40
|
Author: Eric Wong <normalperson@yhbt.net>
|
5
41
|
Date: Thu Jan 13 14:26:58 2011 -0800
|
data/GIT-VERSION-FILE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
GIT_VERSION = 1.
|
1
|
+
GIT_VERSION = 1.2.0
|
data/GIT-VERSION-GEN
CHANGED
data/LATEST
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
-
=== sleepy_penguin 1.
|
1
|
+
=== sleepy_penguin 1.2.0 - epoll GC help / 2011-01-15 12:06 UTC
|
2
2
|
|
3
|
-
|
4
|
-
Documentation updates and cleanups, the website is now
|
5
|
-
JavaScript-free!
|
3
|
+
One convenience fix:
|
6
4
|
|
7
|
-
|
5
|
+
epoll: prevent IO objects from getting GC-ed
|
6
|
+
|
7
|
+
Users of our code may forget to keep references for their IO
|
8
|
+
objects at all, and since it's not possible for GC to mark
|
9
|
+
kernel memory, we just hold on to the IO objects for them.
|
10
|
+
|
11
|
+
We can't unmark close()d file descriptors, ever, so we don't
|
12
|
+
bother with the EPOLL_CTL_DEL case, either. Just storing IO
|
13
|
+
objects in an array using the raw descriptor as a key will allow
|
14
|
+
bounded space usage just like the in-kernel FD tables as long
|
15
|
+
as the user remembers to close descriptors themselves.
|
8
16
|
|
data/NEWS
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
=== sleepy_penguin 1.2.0 - epoll GC help / 2011-01-15 12:06 UTC
|
2
|
+
|
3
|
+
One convenience fix:
|
4
|
+
|
5
|
+
epoll: prevent IO objects from getting GC-ed
|
6
|
+
|
7
|
+
Users of our code may forget to keep references for their IO
|
8
|
+
objects at all, and since it's not possible for GC to mark
|
9
|
+
kernel memory, we just hold on to the IO objects for them.
|
10
|
+
|
11
|
+
We can't unmark close()d file descriptors, ever, so we don't
|
12
|
+
bother with the EPOLL_CTL_DEL case, either. Just storing IO
|
13
|
+
objects in an array using the raw descriptor as a key will allow
|
14
|
+
bounded space usage just like the in-kernel FD tables as long
|
15
|
+
as the user remembers to close descriptors themselves.
|
16
|
+
|
1
17
|
=== sleepy_penguin 1.1.1 - soft feathers, soft delete / 2011-01-13 22:41 UTC
|
2
18
|
|
3
19
|
SleepyPenguin::Epoll#delete method added for "soft" failures
|
data/ext/sleepy_penguin/epoll.c
CHANGED
@@ -50,6 +50,7 @@ struct rb_epoll {
|
|
50
50
|
int capa;
|
51
51
|
struct epoll_event *events;
|
52
52
|
VALUE io;
|
53
|
+
VALUE marks;
|
53
54
|
int flags;
|
54
55
|
};
|
55
56
|
|
@@ -93,6 +94,7 @@ static void gcmark(void *ptr)
|
|
93
94
|
struct rb_epoll *ep = ptr;
|
94
95
|
|
95
96
|
rb_gc_mark(ep->io);
|
97
|
+
rb_gc_mark(ep->marks);
|
96
98
|
}
|
97
99
|
|
98
100
|
static void gcfree(void *ptr)
|
@@ -122,6 +124,7 @@ static VALUE alloc(VALUE klass)
|
|
122
124
|
self = Data_Make_Struct(klass, struct rb_epoll, gcmark, gcfree, ep);
|
123
125
|
ep->fd = -1;
|
124
126
|
ep->io = Qnil;
|
127
|
+
ep->marks = rb_ary_new();
|
125
128
|
ep->capa = step;
|
126
129
|
ep->flags = EPOLL_CLOEXEC;
|
127
130
|
ep->events = xmalloc(sizeof(struct epoll_event) * ep->capa);
|
@@ -201,6 +204,8 @@ static VALUE ctl(VALUE self, VALUE io, VALUE flags, int op)
|
|
201
204
|
if (rv == -1)
|
202
205
|
rb_sys_fail("epoll_ctl");
|
203
206
|
}
|
207
|
+
if (op == EPOLL_CTL_ADD)
|
208
|
+
rb_ary_store(ep->marks, fd, io);
|
204
209
|
|
205
210
|
return INT2NUM(rv);
|
206
211
|
}
|
@@ -226,6 +231,8 @@ static VALUE set(VALUE self, VALUE io, VALUE flags)
|
|
226
231
|
rv = epoll_ctl(ep->fd, EPOLL_CTL_ADD, fd, &event);
|
227
232
|
if (rv == -1)
|
228
233
|
rb_sys_fail("epoll_ctl - add");
|
234
|
+
|
235
|
+
rb_ary_store(ep->marks, fd, io);
|
229
236
|
return INT2NUM(rv);
|
230
237
|
}
|
231
238
|
rb_sys_fail("epoll_ctl - mod");
|
@@ -514,6 +521,7 @@ static VALUE init_copy(VALUE copy, VALUE orig)
|
|
514
521
|
NIL_P(b->io) && "Ruby broken?");
|
515
522
|
|
516
523
|
ep_check(a);
|
524
|
+
b->marks = a->marks;
|
517
525
|
b->flags = a->flags;
|
518
526
|
b->fd = cloexec_dup(a);
|
519
527
|
if (b->fd == -1) {
|
data/lib/sleepy_penguin.rb
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
$-w = true
|
3
|
+
|
4
|
+
require 'sleepy_penguin'
|
5
|
+
|
6
|
+
class TestEpollGC < Test::Unit::TestCase
|
7
|
+
include SleepyPenguin
|
8
|
+
|
9
|
+
def setup
|
10
|
+
GC.stress = true if GC.respond_to?(:stress=)
|
11
|
+
@ep = Epoll.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
GC.stress = false if GC.respond_to?(:stress=)
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_pipe_no_tailcall(m, depth)
|
19
|
+
add_pipe(m, depth += 1)
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_pipe(m, depth = 0)
|
23
|
+
if depth > 6000
|
24
|
+
rd, wr = IO.pipe
|
25
|
+
warn "wr: #{wr.fileno}"
|
26
|
+
@ep.__send__(m, wr, Epoll::OUT)
|
27
|
+
else
|
28
|
+
add_pipe_no_tailcall(m, depth + 1)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_gc_safety
|
33
|
+
done = false
|
34
|
+
begin
|
35
|
+
if done
|
36
|
+
x = nil
|
37
|
+
@ep.wait(nil, 10) { |flags, obj| p [ flags, x = obj ] }
|
38
|
+
assert x, "#{x.inspect}"
|
39
|
+
break
|
40
|
+
else
|
41
|
+
add_pipe(:add)
|
42
|
+
2048.times { IO.pipe; File.open(__FILE__)}
|
43
|
+
done = true
|
44
|
+
end
|
45
|
+
end while true
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sleepy_penguin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- sleepy_penguin hackers
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-15 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- setup.rb
|
82
82
|
- sleepy_penguin.gemspec
|
83
83
|
- test/test_epoll.rb
|
84
|
+
- test/test_epoll_gc.rb
|
84
85
|
- test/test_eventfd.rb
|
85
86
|
- test/test_timerfd.rb
|
86
87
|
has_rdoc: true
|
@@ -124,4 +125,5 @@ summary: Linux I/O events for Ruby
|
|
124
125
|
test_files:
|
125
126
|
- test/test_epoll.rb
|
126
127
|
- test/test_eventfd.rb
|
128
|
+
- test/test_epoll_gc.rb
|
127
129
|
- test/test_timerfd.rb
|