sleepy_penguin 3.5.0 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: dff861d3873bfcd1a028f7cdc0ae46a1065d4092
4
- data.tar.gz: 19244c89ef9f4a8719e31eaed7354ce88640ff5c
2
+ SHA256:
3
+ metadata.gz: 6412db053027f4ab0d6c29a0053051608ae2a49d8e181198ffbf883a6bb31b19
4
+ data.tar.gz: 77e2b0dc6cc44e4f9f8f9fbd0b3c8739ccb0727882d27416404ad597f4029827
5
5
  SHA512:
6
- metadata.gz: 7a82315acdb00dead8609707ed1fe9c5d649c58997170b0fbd0d600a0531bc100f6d57b09fc1fe9ebe4e3f1b1d0e0a967dd0627b26e87e1928f4439aa17b454c
7
- data.tar.gz: 48ff2a95beb3a28150504ddcf7d5e3f475a92b4379aad96db219dd8556872cd0e4351392f72e91ab5fd608cc597e80374134f4340227d31a4f6a5f5a6840eaae
6
+ metadata.gz: 24fbb2975efd8e9ad6ab515775510ecd3337ad8652aabc744a9ea99564e27a78f11985d0d4458c6a945d8365dbb5e81679204918ca5e61db71acac387d1e4188
7
+ data.tar.gz: 8f136eadb671aa24916eed1fd8daa553a9ab077462fe0361f9a29413f713066453ad853b470da5c2b3b5b15d35b2468cec3de1413507e59592c35aac0a217c28
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  cgit_url: https://bogomips.org/sleepy_penguin.git
3
- git_url: git://bogomips.org/sleepy_penguin.git
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
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v3.5.0
4
+ DEF_VER=v3.5.1
5
5
  GVH=ext/sleepy_penguin/git_version.h
6
6
 
7
7
  LF='
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
- git://bogomips.org/sleepy_penguin.git
43
- git://repo.or.cz/sleepy_penguin.git (mirror)
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
- * http://repo.or.cz/w/sleepy_penguin.git (gitweb)
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
@@ -34,4 +34,5 @@ have_func('rb_thread_fd_close')
34
34
  have_func('rb_update_max_fd')
35
35
  have_func('rb_fd_fix_cloexec')
36
36
  have_func('rb_io_get_io')
37
+ have_func('rb_struct_size')
37
38
  create_makefile('sleepy_penguin_ext')
@@ -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 (err) {
107
- errno = err;
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
  }
@@ -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
- static void event_set(struct kevent *event, VALUE *chg)
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
- uintptr_t ident = (uintptr_t)NUM2ULONG(chg[0]);
235
- short filter = NUM2SHORT(chg[1]);
236
- unsigned short flags = NUM2USHORT(chg[2]);
237
- unsigned fflags = (unsigned)NUM2UINT(chg[3]);
238
- intptr_t data = (intptr_t)NUM2LONG(chg[4]);
239
- void *udata = (void *)chg[5];
240
-
241
- EV_SET(event, ident, filter, flags, fflags, data, udata);
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(VALUE **ptr, VALUE *len, VALUE *event)
302
+ static void unpack_event(struct kevent *ev, VALUE event)
246
303
  {
247
- switch (TYPE(*event)) {
304
+ switch (TYPE(event)) {
248
305
  case T_STRUCT:
249
306
  if (RBX_STRUCT) {
250
- *event = rb_funcall(*event, rb_intern("to_a"), 0, 0);
307
+ event = rb_funcall(event, rb_intern("to_a"), 0, 0);
251
308
  /* fall-through to T_ARRAY */
252
309
  } else {
253
- *len = RSTRUCT_LEN(*event);
254
- *ptr = RSTRUCT_PTR(*event);
310
+ ev_set_struct(ev, event);
255
311
  return;
256
312
  }
257
313
  case T_ARRAY:
258
- *len = RARRAY_LEN(*event);
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 = RARRAY_PTR(changelist);
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
- VALUE clen;
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
- event = changelist;
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");
@@ -27,8 +27,7 @@ class SleepyPenguin::Epoll
27
27
  return if @pid == $$
28
28
  return if @io.closed?
29
29
  objects = @copies.values
30
- @copies.each_key { |epio| epio.close }
31
- @copies.clear
30
+ @copies.each_key(&:close).clear
32
31
  __ep_reinit
33
32
  objects.each do |obj|
34
33
  io_dup = @io.dup
@@ -73,7 +73,7 @@ class SleepyPenguin::Kqueue
73
73
  end
74
74
 
75
75
  if block_given?
76
- n = @io.kevent(changelist, *args) do |ident,filter,flags,
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
- n = @io.kevent(changelist, *args)
85
+ @io.kevent(changelist, *args)
86
86
  end
87
87
  end
88
88
 
@@ -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.0').dup
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]
@@ -6,6 +6,7 @@ class TestKqueue < Test::Unit::TestCase
6
6
  def test_kqueue
7
7
  kq = Kqueue.new
8
8
  assert_kind_of IO, kq.to_io
9
+ assert_predicate kq.to_io, :close_on_exec?
9
10
  rd, wr = IO.pipe
10
11
  ev = Kevent[rd.fileno, EvFilt::READ, Ev::ADD|Ev::ONESHOT, 0, 0, rd]
11
12
  thr = Thread.new do
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.0
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: 2017-03-22 00:00:00.000000000 Z
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.6.10
143
+ rubygems_version: 2.7.7
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Linux I/O events for Ruby