kgio 2.5.0 → 2.6.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 +57 -0
- data/GIT-VERSION-FILE +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/LATEST +4 -8
- data/NEWS +6 -0
- data/ext/kgio/accept.c +21 -8
- data/ext/kgio/blocking_io_region.h +4 -1
- data/ext/kgio/missing_accept4.h +2 -2
- data/test/test_accept_flags.rb +49 -0
- metadata +6 -4
data/.manifest
CHANGED
data/ChangeLog
CHANGED
@@ -1,5 +1,62 @@
|
|
1
1
|
ChangeLog from http://bogomips.org/kgio.git
|
2
2
|
|
3
|
+
commit dcaa9f9be83bfd59503033ae8f8eeca79c68c9df
|
4
|
+
Author: Eric Wong <normalperson@yhbt.net>
|
5
|
+
Date: Thu Jul 14 18:54:37 2011 -0700
|
6
|
+
|
7
|
+
kgio 2.6.0 - minor feature update and cleanups
|
8
|
+
|
9
|
+
We now export SOCK_NONBLOCK, SOCK_CLOEXEC constants in the Kgio
|
10
|
+
namespace to make kgio_tryaccept/kgio_accept easier-to-use.
|
11
|
+
There are also some minor internal cleanups.
|
12
|
+
|
13
|
+
commit 8baed92a7c02adcc913bcc7760b77a240b529c63
|
14
|
+
Author: Eric Wong <normalperson@yhbt.net>
|
15
|
+
Date: Thu Jul 14 17:32:10 2011 -0700
|
16
|
+
|
17
|
+
add prototype for rb_thread_blocking_io_region()
|
18
|
+
|
19
|
+
It's no in the public headers, but Ruby 1.9.3 will have it and
|
20
|
+
it's still superior to rb_thread_blocking_region() even though
|
21
|
+
it's not ideal.
|
22
|
+
|
23
|
+
commit 823f41d0f86dda497c166a839d8215275f5d48a0
|
24
|
+
Author: Eric Wong <normalperson@yhbt.net>
|
25
|
+
Date: Thu Jul 14 17:29:57 2011 -0700
|
26
|
+
|
27
|
+
missing_accept4: don't use FD_CLOEXEC for SOCK_CLOEXEC emulation
|
28
|
+
|
29
|
+
It's too confusing and may break binary compatibility if the
|
30
|
+
system is later upgraded.
|
31
|
+
|
32
|
+
commit 142beefba460685fea5b6646e1ba629f9ee207b3
|
33
|
+
Author: Eric Wong <normalperson@yhbt.net>
|
34
|
+
Date: Thu Jul 14 17:29:05 2011 -0700
|
35
|
+
|
36
|
+
accept.c: fix RDoc for new Kgio::SOCK_* constants
|
37
|
+
|
38
|
+
We don't want people using the compatibility constants
|
39
|
+
since they're actually broken on systems with real accept4().
|
40
|
+
|
41
|
+
commit c22f2b5ebccbca8e04aa22821964f67c4a81c675
|
42
|
+
Author: Eric Wong <normalperson@yhbt.net>
|
43
|
+
Date: Wed Jul 6 19:11:47 2011 -0700
|
44
|
+
|
45
|
+
export SOCK_NONBLOCK, SOCK_CLOEXEC constants in Kgio
|
46
|
+
|
47
|
+
It's more reliable than relying on IO::NONBLOCK and
|
48
|
+
Fcntl::FD_CLOEXEC constants. The existing constants are not
|
49
|
+
guaranteed to be equivalent to what accept4() takes even
|
50
|
+
though the current Linux implementation does it this way.
|
51
|
+
|
52
|
+
commit 8e1a53f99a752d8ccba324560a9e52bf6e80680d
|
53
|
+
Author: Eric Wong <normalperson@yhbt.net>
|
54
|
+
Date: Wed Jul 6 18:32:39 2011 -0700
|
55
|
+
|
56
|
+
accept.c: reinstate errno after calling my_fileno()
|
57
|
+
|
58
|
+
my_fileno() may change errno on some Rubies
|
59
|
+
|
3
60
|
commit e720827b48c3318627d1471ad4ec90d6166520fd
|
4
61
|
Author: Eric Wong <normalperson@yhbt.net>
|
5
62
|
Date: Fri Jun 17 19:01:06 2011 -0700
|
data/GIT-VERSION-FILE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
GIT_VERSION = 2.
|
1
|
+
GIT_VERSION = 2.6.0
|
data/GIT-VERSION-GEN
CHANGED
data/LATEST
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
=== kgio 2.
|
1
|
+
=== kgio 2.6.0 - minor feature update and cleanups / 2011-07-15 02:01 UTC
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
kgio_* API.
|
7
|
-
|
8
|
-
* The kgio_wait_*able methods in Kgio::DefaultWaiters
|
9
|
-
now accept an optional timeout argument.
|
3
|
+
We now export SOCK_NONBLOCK, SOCK_CLOEXEC constants in the Kgio
|
4
|
+
namespace to make kgio_tryaccept/kgio_accept easier-to-use.
|
5
|
+
There are also some minor internal cleanups.
|
10
6
|
|
data/NEWS
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== kgio 2.6.0 - minor feature update and cleanups / 2011-07-15 02:01 UTC
|
2
|
+
|
3
|
+
We now export SOCK_NONBLOCK, SOCK_CLOEXEC constants in the Kgio
|
4
|
+
namespace to make kgio_tryaccept/kgio_accept easier-to-use.
|
5
|
+
There are also some minor internal cleanups.
|
6
|
+
|
1
7
|
=== kgio 2.5.0 - a minor feature update / 2011-06-20 19:30 UTC
|
2
8
|
|
3
9
|
* Kgio::File.tryopen method added. It is like File.open
|
data/ext/kgio/accept.c
CHANGED
@@ -204,6 +204,7 @@ retry:
|
|
204
204
|
if (force_nonblock)
|
205
205
|
return Qnil;
|
206
206
|
a->fd = my_fileno(a->accept_io);
|
207
|
+
errno = EAGAIN;
|
207
208
|
set_blocking_or_block(a->fd);
|
208
209
|
#ifdef ECONNABORTED
|
209
210
|
case ECONNABORTED:
|
@@ -282,8 +283,8 @@ static VALUE addr_bang(VALUE io)
|
|
282
283
|
* value of +Kgio.accept_cloexec+ and +Kgio.accept_nonblock+. +flags+
|
283
284
|
* is a bitmask that may contain any combination of:
|
284
285
|
*
|
285
|
-
* -
|
286
|
-
* -
|
286
|
+
* - Kgio::SOCK_CLOEXEC - close-on-exec flag
|
287
|
+
* - Kgio::SOCK_NONBLOCK - non-blocking flag
|
287
288
|
*/
|
288
289
|
static VALUE tcp_tryaccept(int argc, VALUE *argv, VALUE self)
|
289
290
|
{
|
@@ -319,8 +320,8 @@ static VALUE tcp_tryaccept(int argc, VALUE *argv, VALUE self)
|
|
319
320
|
* value of +Kgio.accept_cloexec+ and +Kgio.accept_nonblock+. +flags+
|
320
321
|
* is a bitmask that may contain any combination of:
|
321
322
|
*
|
322
|
-
* -
|
323
|
-
* -
|
323
|
+
* - Kgio::SOCK_CLOEXEC - close-on-exec flag
|
324
|
+
* - Kgio::SOCK_NONBLOCK - non-blocking flag
|
324
325
|
*/
|
325
326
|
static VALUE tcp_accept(int argc, VALUE *argv, VALUE self)
|
326
327
|
{
|
@@ -353,8 +354,8 @@ static VALUE tcp_accept(int argc, VALUE *argv, VALUE self)
|
|
353
354
|
* value of +Kgio.accept_cloexec+ and +Kgio.accept_nonblock+. +flags+
|
354
355
|
* is a bitmask that may contain any combination of:
|
355
356
|
*
|
356
|
-
* -
|
357
|
-
* -
|
357
|
+
* - Kgio::SOCK_CLOEXEC - close-on-exec flag
|
358
|
+
* - Kgio::SOCK_NONBLOCK - non-blocking flag
|
358
359
|
*/
|
359
360
|
static VALUE unix_tryaccept(int argc, VALUE *argv, VALUE self)
|
360
361
|
{
|
@@ -388,8 +389,8 @@ static VALUE unix_tryaccept(int argc, VALUE *argv, VALUE self)
|
|
388
389
|
* value of +Kgio.accept_cloexec+ and +Kgio.accept_nonblock+. +flags+
|
389
390
|
* is a bitmask that may contain any combination of:
|
390
391
|
*
|
391
|
-
* -
|
392
|
-
* -
|
392
|
+
* - Kgio::SOCK_CLOEXEC - close-on-exec flag
|
393
|
+
* - Kgio::SOCK_NONBLOCK - non-blocking flag
|
393
394
|
*/
|
394
395
|
static VALUE unix_accept(int argc, VALUE *argv, VALUE self)
|
395
396
|
{
|
@@ -495,6 +496,18 @@ void init_kgio_accept(void)
|
|
495
496
|
VALUE cUNIXServer, cTCPServer;
|
496
497
|
VALUE mKgio = rb_define_module("Kgio");
|
497
498
|
|
499
|
+
/*
|
500
|
+
* this maps to the SOCK_NONBLOCK constant in Linux for setting
|
501
|
+
* the non-blocking flag on newly accepted sockets.
|
502
|
+
*/
|
503
|
+
rb_define_const(mKgio, "SOCK_NONBLOCK", INT2NUM(SOCK_NONBLOCK));
|
504
|
+
|
505
|
+
/*
|
506
|
+
* this maps to the SOCK_CLOEXEC constant in Linux for setting
|
507
|
+
* the close-on-exec flag on newly accepted descriptors.
|
508
|
+
*/
|
509
|
+
rb_define_const(mKgio, "SOCK_CLOEXEC", INT2NUM(SOCK_CLOEXEC));
|
510
|
+
|
498
511
|
localhost = rb_const_get(mKgio, rb_intern("LOCALHOST"));
|
499
512
|
cKgio_Socket = rb_const_get(mKgio, rb_intern("Socket"));
|
500
513
|
cClientSocket = cKgio_Socket;
|
@@ -1,5 +1,8 @@
|
|
1
1
|
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
|
2
|
-
#
|
2
|
+
# ifdef HAVE_RB_THREAD_IO_BLOCKING_REGION
|
3
|
+
/* temporary API for Ruby 1.9.3 */
|
4
|
+
VALUE rb_thread_io_blocking_region(rb_blocking_function_t *, void *, int);
|
5
|
+
# else
|
3
6
|
# define rb_thread_io_blocking_region(fn,data,fd) \
|
4
7
|
rb_thread_blocking_region((fn),(data),RUBY_UBF_IO,0)
|
5
8
|
# endif
|
data/ext/kgio/missing_accept4.h
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
# include <sys/types.h>
|
6
6
|
# include <sys/socket.h>
|
7
7
|
# ifndef SOCK_CLOEXEC
|
8
|
-
# if (
|
8
|
+
# if (02000000 == O_NONBLOCK)
|
9
9
|
# define SOCK_CLOEXEC 1
|
10
10
|
# define SOCK_NONBLOCK 2
|
11
11
|
# else
|
12
|
-
# define SOCK_CLOEXEC
|
12
|
+
# define SOCK_CLOEXEC 02000000
|
13
13
|
# define SOCK_NONBLOCK O_NONBLOCK
|
14
14
|
# endif
|
15
15
|
# endif
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'fcntl'
|
3
|
+
require 'io/nonblock'
|
4
|
+
$-w = true
|
5
|
+
require 'kgio'
|
6
|
+
|
7
|
+
class TestAcceptFlags < Test::Unit::TestCase
|
8
|
+
def test_accept_flags
|
9
|
+
@host = ENV["TEST_HOST"] || '127.0.0.1'
|
10
|
+
@srv = Kgio::TCPServer.new(@host, 0)
|
11
|
+
@port = @srv.addr[1]
|
12
|
+
|
13
|
+
client = TCPSocket.new(@host, @port)
|
14
|
+
accepted = @srv.kgio_accept(nil, Kgio::SOCK_NONBLOCK)
|
15
|
+
assert_instance_of Kgio::Socket, accepted
|
16
|
+
assert accepted.nonblock?
|
17
|
+
flags = accepted.fcntl(Fcntl::F_GETFD)
|
18
|
+
assert_equal 0, flags & Fcntl::FD_CLOEXEC
|
19
|
+
assert_nil client.close
|
20
|
+
assert_nil accepted.close
|
21
|
+
|
22
|
+
client = TCPSocket.new(@host, @port)
|
23
|
+
accepted = @srv.kgio_accept(nil, Kgio::SOCK_CLOEXEC)
|
24
|
+
assert_instance_of Kgio::Socket, accepted
|
25
|
+
assert ! accepted.nonblock?
|
26
|
+
flags = accepted.fcntl(Fcntl::F_GETFD)
|
27
|
+
assert_equal Fcntl::FD_CLOEXEC, flags & Fcntl::FD_CLOEXEC
|
28
|
+
assert_nil client.close
|
29
|
+
assert_nil accepted.close
|
30
|
+
|
31
|
+
client = TCPSocket.new(@host, @port)
|
32
|
+
accepted = @srv.kgio_accept(nil, Kgio::SOCK_CLOEXEC|Kgio::SOCK_NONBLOCK)
|
33
|
+
assert_instance_of Kgio::Socket, accepted
|
34
|
+
assert accepted.nonblock?
|
35
|
+
flags = accepted.fcntl(Fcntl::F_GETFD)
|
36
|
+
assert_equal Fcntl::FD_CLOEXEC, flags & Fcntl::FD_CLOEXEC
|
37
|
+
assert_nil client.close
|
38
|
+
assert_nil accepted.close
|
39
|
+
|
40
|
+
client = TCPSocket.new(@host, @port)
|
41
|
+
accepted = @srv.kgio_accept(nil, Kgio::SOCK_CLOEXEC|Kgio::SOCK_NONBLOCK)
|
42
|
+
assert_instance_of Kgio::Socket, accepted
|
43
|
+
assert accepted.nonblock?
|
44
|
+
flags = accepted.fcntl(Fcntl::F_GETFD)
|
45
|
+
assert_equal Fcntl::FD_CLOEXEC, flags & Fcntl::FD_CLOEXEC
|
46
|
+
assert_nil client.close
|
47
|
+
assert_nil accepted.close
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kgio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
8
|
+
- 6
|
9
9
|
- 0
|
10
|
-
version: 2.
|
10
|
+
version: 2.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- kgio hackers
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-15 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: wrongdoc
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- test/lib_read_write.rb
|
119
119
|
- test/lib_server_accept.rb
|
120
120
|
- test/test_accept_class.rb
|
121
|
+
- test/test_accept_flags.rb
|
121
122
|
- test/test_autopush.rb
|
122
123
|
- test/test_connect_fd_leak.rb
|
123
124
|
- test/test_cross_thread_close.rb
|
@@ -184,6 +185,7 @@ test_files:
|
|
184
185
|
- test/test_unix_connect.rb
|
185
186
|
- test/test_pipe_read_write.rb
|
186
187
|
- test/test_unix_server.rb
|
188
|
+
- test/test_accept_flags.rb
|
187
189
|
- test/test_socketpair_read_write.rb
|
188
190
|
- test/test_tcp_server.rb
|
189
191
|
- test/test_unix_server_read_client_write.rb
|