sleepy_penguin 3.5.0 → 3.5.1
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.
- checksums.yaml +5 -5
- data/.olddoc.yml +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/README +3 -3
- data/ext/sleepy_penguin/extconf.rb +1 -0
- data/ext/sleepy_penguin/init.c +3 -5
- data/ext/sleepy_penguin/kqueue.c +77 -44
- data/lib/sleepy_penguin/epoll.rb +1 -2
- data/lib/sleepy_penguin/kqueue.rb +2 -2
- data/sleepy_penguin.gemspec +1 -1
- data/test/test_kqueue.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6412db053027f4ab0d6c29a0053051608ae2a49d8e181198ffbf883a6bb31b19
|
4
|
+
data.tar.gz: 77e2b0dc6cc44e4f9f8f9fbd0b3c8739ccb0727882d27416404ad597f4029827
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24fbb2975efd8e9ad6ab515775510ecd3337ad8652aabc744a9ea99564e27a78f11985d0d4458c6a945d8365dbb5e81679204918ca5e61db71acac387d1e4188
|
7
|
+
data.tar.gz: 8f136eadb671aa24916eed1fd8daa553a9ab077462fe0361f9a29413f713066453ad853b470da5c2b3b5b15d35b2468cec3de1413507e59592c35aac0a217c28
|
data/.olddoc.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
2
|
cgit_url: https://bogomips.org/sleepy_penguin.git
|
3
|
-
git_url:
|
3
|
+
git_url: https://bogomips.org/sleepy_penguin.git
|
4
4
|
rdoc_url: https://bogomips.org/sleepy_penguin/
|
5
5
|
ml_url: https://bogomips.org/sleepy-penguin/
|
6
6
|
public_email: sleepy-penguin@bogomips.org
|
data/GIT-VERSION-GEN
CHANGED
data/README
CHANGED
@@ -39,14 +39,14 @@ Unpack it, and run "ruby setup.rb"
|
|
39
39
|
|
40
40
|
You can get the latest source via git from the following locations:
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
https://bogomips.org/sleepy_penguin.git
|
43
|
+
https://repo.or.cz/sleepy_penguin.git (mirror)
|
44
44
|
|
45
45
|
You may browse the code from the web and download the latest snapshot
|
46
46
|
tarballs here:
|
47
47
|
|
48
48
|
* https://bogomips.org/sleepy_penguin.git
|
49
|
-
*
|
49
|
+
* https://repo.or.cz/w/sleepy_penguin.git (gitweb)
|
50
50
|
|
51
51
|
Inline patches (from "git format-patch") to the mailing list are
|
52
52
|
preferred because they allow code review and comments in the reply to
|
data/ext/sleepy_penguin/init.c
CHANGED
@@ -101,15 +101,13 @@ static struct rb_sp_tlsbuf *alloc_tlsbuf(size_t size)
|
|
101
101
|
size_t bytes = size + sizeof(struct rb_sp_tlsbuf);
|
102
102
|
struct rb_sp_tlsbuf *buf;
|
103
103
|
void *ptr;
|
104
|
-
int err = posix_memalign(&ptr, rb_sp_l1_cache_line_size, bytes);
|
105
104
|
|
106
|
-
if (
|
107
|
-
|
105
|
+
if (size >= UINT32_MAX ||
|
106
|
+
posix_memalign(&ptr, rb_sp_l1_cache_line_size, bytes))
|
108
107
|
rb_memerror(); /* fatal */
|
109
|
-
}
|
110
108
|
|
111
109
|
buf = ptr;
|
112
|
-
buf->capa = size;
|
110
|
+
buf->capa = (uint32_t)size;
|
113
111
|
|
114
112
|
return buf;
|
115
113
|
}
|
data/ext/sleepy_penguin/kqueue.c
CHANGED
@@ -18,6 +18,9 @@
|
|
18
18
|
#ifndef RARRAY_LENINT
|
19
19
|
# define RARRAY_LENINT(ary) (int)RARRAY_LEN(ary)
|
20
20
|
#endif
|
21
|
+
#ifndef RARRAY_CONST_PTR
|
22
|
+
# define RARRAY_CONST_PTR(ary) RARRAY_PTR(ary)
|
23
|
+
#endif
|
21
24
|
#ifndef NUM2SHORT
|
22
25
|
# define NUM2SHORT(n) (short)NUM2INT(n)
|
23
26
|
#endif
|
@@ -110,6 +113,7 @@ static VALUE s_new(VALUE klass)
|
|
110
113
|
{
|
111
114
|
VALUE rv;
|
112
115
|
int fd = kqueue();
|
116
|
+
int flags;
|
113
117
|
|
114
118
|
if (fd < 0) {
|
115
119
|
/*
|
@@ -122,9 +126,12 @@ static VALUE s_new(VALUE klass)
|
|
122
126
|
rb_sys_fail("kqueue");
|
123
127
|
}
|
124
128
|
|
129
|
+
flags = fcntl(fd, F_GETFD);
|
130
|
+
if (flags != -1)
|
131
|
+
fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
|
132
|
+
|
125
133
|
rv = INT2FIX(fd);
|
126
134
|
|
127
|
-
/* This will set FD_CLOEXEC on Ruby 2.0.0+: */
|
128
135
|
return rb_call_super(1, &rv);
|
129
136
|
}
|
130
137
|
|
@@ -229,35 +236,82 @@ static VALUE do_kevent(struct kq_per_thread *kpt)
|
|
229
236
|
return kevent_result(kpt, (int)nevents);
|
230
237
|
}
|
231
238
|
|
232
|
-
|
239
|
+
#if defined(HAVE_RB_STRUCT_SIZE) && defined(RSTRUCT_GET)
|
240
|
+
static void ev_set_struct(struct kevent *ev, VALUE event)
|
241
|
+
{
|
242
|
+
if (rb_struct_size(event) == INT2NUM(6)) {
|
243
|
+
uintptr_t ident = (uintptr_t)NUM2ULONG(RSTRUCT_GET(event, 0));
|
244
|
+
short filter = NUM2SHORT(RSTRUCT_GET(event, 1));
|
245
|
+
unsigned short flags = NUM2USHORT(RSTRUCT_GET(event, 2));
|
246
|
+
unsigned fflags = (unsigned)NUM2UINT(RSTRUCT_GET(event, 3));
|
247
|
+
intptr_t data = (intptr_t)NUM2LONG(RSTRUCT_GET(event, 4));
|
248
|
+
void *udata = (void *)RSTRUCT_GET(event, 5);
|
249
|
+
|
250
|
+
EV_SET(ev, ident, filter, flags, fflags, data, udata);
|
251
|
+
} else {
|
252
|
+
rb_raise(rb_eTypeError, "unsupported struct in changelist");
|
253
|
+
}
|
254
|
+
}
|
255
|
+
#elif RBX_STRUCT == 0 && defined(RSTRUCT_LEN) && defined(RSTRUCT_PTR)
|
256
|
+
/* legacy MRI */
|
257
|
+
static void ev_set_struct(struct kevent *ev, VALUE event)
|
258
|
+
{
|
259
|
+
long len = RSTRUCT_LEN(*event);
|
260
|
+
if (len == 6) {
|
261
|
+
const VALUE *ptr = RSTRUCT_PTR(*event);
|
262
|
+
uintptr_t ident = (uintptr_t)NUM2ULONG(ptr[0]);
|
263
|
+
short filter = NUM2SHORT(ptr[1]);
|
264
|
+
unsigned short flags = NUM2USHORT(ptr[2]);
|
265
|
+
unsigned fflags = (unsigned)NUM2UINT(ptr[3]);
|
266
|
+
intptr_t data = (intptr_t)NUM2LONG(ptr[4]);
|
267
|
+
void *udata = (void *)ptr[5];
|
268
|
+
|
269
|
+
EV_SET(event, ident, filter, flags, fflags, data, udata);
|
270
|
+
} else {
|
271
|
+
rb_raise(rb_eTypeError, "unsupported struct in changelist");
|
272
|
+
}
|
273
|
+
}
|
274
|
+
#else
|
275
|
+
static void ev_set_struct(struct kevent *ev, VALUE event)
|
276
|
+
{
|
277
|
+
rb_raise(rb_eTypeError, "unsupported struct in changelist");
|
278
|
+
}
|
279
|
+
#endif
|
280
|
+
|
281
|
+
static void ev_set_ary(struct kevent *ev, VALUE event)
|
233
282
|
{
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
283
|
+
long len = RARRAY_LEN(event);
|
284
|
+
const VALUE *ptr = RARRAY_CONST_PTR(event);
|
285
|
+
|
286
|
+
if (len == 6) {
|
287
|
+
uintptr_t ident = (uintptr_t)NUM2ULONG(ptr[0]);
|
288
|
+
short filter = NUM2SHORT(ptr[1]);
|
289
|
+
unsigned short flags = NUM2USHORT(ptr[2]);
|
290
|
+
unsigned fflags = (unsigned)NUM2UINT(ptr[3]);
|
291
|
+
intptr_t data = (intptr_t)NUM2LONG(ptr[4]);
|
292
|
+
void *udata = (void *)ptr[5];
|
293
|
+
|
294
|
+
EV_SET(ev, ident, filter, flags, fflags, data, udata);
|
295
|
+
return;
|
296
|
+
}
|
297
|
+
rb_raise(rb_eTypeError,
|
298
|
+
"changelist must be an array of 6-element arrays or structs");
|
242
299
|
}
|
243
300
|
|
244
301
|
/* sets ptr and len */
|
245
|
-
static void unpack_event(
|
302
|
+
static void unpack_event(struct kevent *ev, VALUE event)
|
246
303
|
{
|
247
|
-
switch (TYPE(
|
304
|
+
switch (TYPE(event)) {
|
248
305
|
case T_STRUCT:
|
249
306
|
if (RBX_STRUCT) {
|
250
|
-
|
307
|
+
event = rb_funcall(event, rb_intern("to_a"), 0, 0);
|
251
308
|
/* fall-through to T_ARRAY */
|
252
309
|
} else {
|
253
|
-
|
254
|
-
*ptr = RSTRUCT_PTR(*event);
|
310
|
+
ev_set_struct(ev, event);
|
255
311
|
return;
|
256
312
|
}
|
257
313
|
case T_ARRAY:
|
258
|
-
|
259
|
-
*ptr = RARRAY_PTR(*event);
|
260
|
-
return;
|
314
|
+
ev_set_ary(ev, event);
|
261
315
|
default:
|
262
316
|
rb_raise(rb_eTypeError, "unsupported type in changelist");
|
263
317
|
}
|
@@ -265,24 +319,11 @@ static void unpack_event(VALUE **ptr, VALUE *len, VALUE *event)
|
|
265
319
|
|
266
320
|
static void ary2eventlist(struct kevent *events, VALUE changelist)
|
267
321
|
{
|
268
|
-
VALUE *chg =
|
322
|
+
const VALUE *chg = RARRAY_CONST_PTR(changelist);
|
269
323
|
long i = RARRAY_LEN(changelist);
|
270
|
-
VALUE event;
|
271
324
|
|
272
|
-
for (; --i >= 0; chg++)
|
273
|
-
|
274
|
-
VALUE *cptr;
|
275
|
-
|
276
|
-
event = *chg;
|
277
|
-
unpack_event(&cptr, &clen, &event);
|
278
|
-
if (clen != 6)
|
279
|
-
goto out_list;
|
280
|
-
event_set(events++, cptr);
|
281
|
-
}
|
282
|
-
return;
|
283
|
-
out_list:
|
284
|
-
rb_raise(rb_eTypeError,
|
285
|
-
"changelist must be an array of 6-element arrays or structs");
|
325
|
+
for (; --i >= 0; chg++)
|
326
|
+
unpack_event(events++, *chg);
|
286
327
|
}
|
287
328
|
|
288
329
|
/*
|
@@ -290,20 +331,12 @@ out_list:
|
|
290
331
|
*/
|
291
332
|
static void changelist_prepare(struct kevent *events, VALUE changelist)
|
292
333
|
{
|
293
|
-
VALUE *cptr;
|
294
|
-
VALUE clen;
|
295
|
-
VALUE event;
|
296
|
-
|
297
334
|
switch (TYPE(changelist)) {
|
298
335
|
case T_ARRAY:
|
299
336
|
ary2eventlist(events, changelist);
|
300
337
|
return;
|
301
|
-
case T_STRUCT:
|
302
|
-
|
303
|
-
unpack_event(&cptr, &clen, &event);
|
304
|
-
if (clen != 6)
|
305
|
-
rb_raise(rb_eTypeError, "event is not a Kevent struct");
|
306
|
-
event_set(events, cptr);
|
338
|
+
case T_STRUCT: /* single event */
|
339
|
+
unpack_event(events, changelist);
|
307
340
|
return;
|
308
341
|
default:
|
309
342
|
rb_bug("changelist_prepare not type filtered by sp_kevent");
|
data/lib/sleepy_penguin/epoll.rb
CHANGED
@@ -73,7 +73,7 @@ class SleepyPenguin::Kqueue
|
|
73
73
|
end
|
74
74
|
|
75
75
|
if block_given?
|
76
|
-
|
76
|
+
@io.kevent(changelist, *args) do |ident,filter,flags,
|
77
77
|
fflags,data,udata|
|
78
78
|
# This may raise and cause events to be lost,
|
79
79
|
# that's the users' fault/problem
|
@@ -82,7 +82,7 @@ class SleepyPenguin::Kqueue
|
|
82
82
|
fflags, data, udata)
|
83
83
|
end
|
84
84
|
else
|
85
|
-
|
85
|
+
@io.kevent(changelist, *args)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
data/sleepy_penguin.gemspec
CHANGED
@@ -3,7 +3,7 @@ manifest = File.exist?('.manifest') ?
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = %q{sleepy_penguin}
|
6
|
-
s.version = (ENV['VERSION'] || '3.5.
|
6
|
+
s.version = (ENV['VERSION'] || '3.5.1').dup
|
7
7
|
s.homepage = 'https://bogomips.org/sleepy_penguin/'
|
8
8
|
s.authors = ['sleepy_penguin hackers']
|
9
9
|
s.description = File.read('README').split("\n\n")[1]
|
data/test/test_kqueue.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sleepy_penguin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sleepy_penguin hackers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.7.7
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Linux I/O events for Ruby
|