eventmachine 0.12.6-java → 0.12.8-java
Sign up to get free protection for your applications and to get access to all the features.
- data/{docs/README → README} +21 -13
- data/Rakefile +5 -3
- data/docs/DEFERRABLES +0 -5
- data/docs/INSTALL +2 -4
- data/docs/LEGAL +1 -1
- data/docs/LIGHTWEIGHT_CONCURRENCY +0 -2
- data/docs/PURE_RUBY +0 -2
- data/docs/RELEASE_NOTES +0 -2
- data/docs/SMTP +0 -7
- data/docs/SPAWNED_PROCESSES +0 -4
- data/docs/TODO +0 -2
- data/eventmachine.gemspec +17 -8
- data/examples/ex_channel.rb +43 -0
- data/examples/ex_queue.rb +2 -0
- data/examples/helper.rb +2 -0
- data/ext/cmain.cpp +119 -20
- data/ext/cplusplus.cpp +15 -6
- data/ext/ed.cpp +303 -93
- data/ext/ed.h +49 -22
- data/ext/em.cpp +368 -42
- data/ext/em.h +43 -6
- data/ext/eventmachine.h +21 -8
- data/ext/eventmachine_cpp.h +1 -0
- data/ext/extconf.rb +4 -0
- data/ext/kb.cpp +1 -2
- data/ext/pipe.cpp +1 -3
- data/ext/project.h +21 -0
- data/ext/rubymain.cpp +232 -32
- data/ext/ssl.cpp +38 -1
- data/ext/ssl.h +5 -1
- data/java/src/com/rubyeventmachine/Application.java +7 -3
- data/java/src/com/rubyeventmachine/EmReactor.java +16 -1
- data/java/src/com/rubyeventmachine/tests/ConnectTest.java +25 -3
- data/lib/{protocols → em}/buftok.rb +16 -5
- data/lib/em/callback.rb +26 -0
- data/lib/em/channel.rb +57 -0
- data/lib/em/connection.rb +505 -0
- data/lib/em/deferrable.rb +144 -165
- data/lib/em/file_watch.rb +54 -0
- data/lib/em/future.rb +24 -25
- data/lib/em/messages.rb +1 -1
- data/lib/em/process_watch.rb +44 -0
- data/lib/em/processes.rb +58 -52
- data/lib/em/protocols.rb +35 -0
- data/lib/em/protocols/header_and_content.rb +138 -0
- data/lib/em/protocols/httpclient.rb +263 -0
- data/lib/em/protocols/httpclient2.rb +582 -0
- data/lib/{protocols → em/protocols}/line_and_text.rb +2 -2
- data/lib/em/protocols/linetext2.rb +160 -0
- data/lib/{protocols → em/protocols}/memcache.rb +37 -7
- data/lib/em/protocols/object_protocol.rb +39 -0
- data/lib/em/protocols/postgres3.rb +247 -0
- data/lib/em/protocols/saslauth.rb +175 -0
- data/lib/em/protocols/smtpclient.rb +331 -0
- data/lib/em/protocols/smtpserver.rb +547 -0
- data/lib/em/protocols/stomp.rb +200 -0
- data/lib/{protocols → em/protocols}/tcptest.rb +21 -25
- data/lib/em/queue.rb +61 -0
- data/lib/em/spawnable.rb +53 -56
- data/lib/em/streamer.rb +92 -74
- data/lib/em/timers.rb +55 -0
- data/lib/em/version.rb +3 -0
- data/lib/eventmachine.rb +1008 -1298
- data/lib/evma.rb +1 -1
- data/lib/jeventmachine.rb +106 -101
- data/lib/pr_eventmachine.rb +47 -36
- data/tasks/project.rake +2 -1
- data/tests/client.crt +31 -0
- data/tests/client.key +51 -0
- data/tests/test_attach.rb +18 -0
- data/tests/test_basic.rb +108 -54
- data/tests/test_channel.rb +63 -0
- data/tests/test_connection_count.rb +2 -2
- data/tests/test_epoll.rb +109 -110
- data/tests/test_errors.rb +36 -36
- data/tests/test_exc.rb +22 -25
- data/tests/test_file_watch.rb +49 -0
- data/tests/test_futures.rb +77 -93
- data/tests/test_hc.rb +2 -2
- data/tests/test_httpclient.rb +55 -52
- data/tests/test_httpclient2.rb +110 -112
- data/tests/test_inactivity_timeout.rb +30 -0
- data/tests/test_kb.rb +8 -9
- data/tests/test_ltp2.rb +274 -277
- data/tests/test_next_tick.rb +91 -65
- data/tests/test_object_protocol.rb +37 -0
- data/tests/test_process_watch.rb +48 -0
- data/tests/test_processes.rb +56 -23
- data/tests/test_proxy_connection.rb +92 -0
- data/tests/test_pure.rb +1 -5
- data/tests/test_queue.rb +44 -0
- data/tests/test_running.rb +9 -14
- data/tests/test_sasl.rb +32 -34
- data/tests/test_send_file.rb +175 -176
- data/tests/test_servers.rb +37 -41
- data/tests/test_smtpserver.rb +47 -55
- data/tests/test_spawn.rb +284 -291
- data/tests/test_ssl_args.rb +1 -1
- data/tests/test_ssl_methods.rb +1 -1
- data/tests/test_ssl_verify.rb +82 -0
- data/tests/test_timers.rb +81 -88
- data/tests/test_ud.rb +0 -7
- data/tests/testem.rb +1 -1
- metadata +52 -36
- data/lib/em/eventable.rb +0 -39
- data/lib/eventmachine_version.rb +0 -31
- data/lib/protocols/header_and_content.rb +0 -129
- data/lib/protocols/httpcli2.rb +0 -803
- data/lib/protocols/httpclient.rb +0 -270
- data/lib/protocols/linetext2.rb +0 -161
- data/lib/protocols/postgres.rb +0 -261
- data/lib/protocols/saslauth.rb +0 -179
- data/lib/protocols/smtpclient.rb +0 -308
- data/lib/protocols/smtpserver.rb +0 -556
- data/lib/protocols/stomp.rb +0 -153
- data/tests/test_eventables.rb +0 -77
data/tests/test_attach.rb
CHANGED
@@ -80,4 +80,22 @@ class TestAttach < Test::Unit::TestCase
|
|
80
80
|
|
81
81
|
assert_equal $read, "ghi\n"
|
82
82
|
end
|
83
|
+
|
84
|
+
module PipeReader
|
85
|
+
def receive_data data
|
86
|
+
$read = data
|
87
|
+
EM.stop
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_read_write_pipe
|
92
|
+
EM.run{
|
93
|
+
$r, $w = IO.pipe
|
94
|
+
EM.attach $r, PipeReader
|
95
|
+
writer = EM.attach($w)
|
96
|
+
writer.send_data 'ghi'
|
97
|
+
}
|
98
|
+
|
99
|
+
assert_equal $read, "ghi"
|
100
|
+
end
|
83
101
|
end
|
data/tests/test_basic.rb
CHANGED
@@ -26,6 +26,7 @@
|
|
26
26
|
|
27
27
|
$:.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
|
28
28
|
require 'eventmachine'
|
29
|
+
require 'socket'
|
29
30
|
require 'test/unit'
|
30
31
|
|
31
32
|
class TestBasic < Test::Unit::TestCase
|
@@ -42,16 +43,16 @@ class TestBasic < Test::Unit::TestCase
|
|
42
43
|
|
43
44
|
def test_libtype
|
44
45
|
lt = EventMachine.library_type
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
46
|
+
em_lib = (ENV["EVENTMACHINE_LIBRARY"] || $eventmachine_library || :xxx).to_sym
|
47
|
+
|
48
|
+
# Running from test runner, under jruby.
|
49
|
+
if RUBY_PLATFORM == 'java'
|
50
|
+
unless em_lib == :pure_ruby
|
51
|
+
assert_equal( :java, lt )
|
52
|
+
return
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
55
56
|
case em_lib
|
56
57
|
when :pure_ruby
|
57
58
|
assert_equal( :pure_ruby, lt )
|
@@ -60,12 +61,12 @@ class TestBasic < Test::Unit::TestCase
|
|
60
61
|
when :java
|
61
62
|
assert_equal( :java, lt )
|
62
63
|
else
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
# Running from jruby as a standalone test.
|
65
|
+
if RUBY_PLATFORM == 'java'
|
66
|
+
assert_equal( :java, lt )
|
67
|
+
else
|
68
|
+
assert_equal( :extension, lt )
|
69
|
+
end
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
@@ -116,10 +117,10 @@ class TestBasic < Test::Unit::TestCase
|
|
116
117
|
# even after the supplied block completes.
|
117
118
|
def test_run_block
|
118
119
|
assert !EM.reactor_running?
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
120
|
+
a = nil
|
121
|
+
EM.run_block { a = "Worked" }
|
122
|
+
assert a
|
123
|
+
assert !EM.reactor_running?
|
123
124
|
end
|
124
125
|
|
125
126
|
|
@@ -136,24 +137,24 @@ class TestBasic < Test::Unit::TestCase
|
|
136
137
|
TestPort = 9070
|
137
138
|
|
138
139
|
class UnbindError < EM::Connection
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
140
|
+
def initialize *args
|
141
|
+
super
|
142
|
+
end
|
143
|
+
def connection_completed
|
144
|
+
close_connection_after_writing
|
145
|
+
end
|
146
|
+
def unbind
|
147
|
+
raise "Blooey"
|
148
|
+
end
|
148
149
|
end
|
149
150
|
|
150
151
|
def xxx_test_unbind_error
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
152
|
+
assert_raises( RuntimeError ) {
|
153
|
+
EM.run {
|
154
|
+
EM.start_server TestHost, TestPort
|
155
|
+
EM.connect TestHost, TestPort, UnbindError
|
156
|
+
}
|
157
|
+
}
|
157
158
|
end
|
158
159
|
|
159
160
|
#------------------------------------
|
@@ -177,26 +178,26 @@ class TestBasic < Test::Unit::TestCase
|
|
177
178
|
#
|
178
179
|
|
179
180
|
class PostInitError < EM::Connection
|
180
|
-
|
181
|
-
|
182
|
-
|
181
|
+
def post_init
|
182
|
+
aaa bbb # should produce a Ruby exception
|
183
|
+
end
|
183
184
|
end
|
184
185
|
# This test causes issues, the machine becomes unreleasable after
|
185
186
|
# release_machine suffers an exception in event_callback.
|
186
187
|
def xxx_test_post_init_error
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
188
|
+
assert_raises( EventMachine::ConnectionNotBound ) {
|
189
|
+
EM.run {
|
190
|
+
EM::Timer.new(1) {EM.stop}
|
191
|
+
EM.start_server TestHost, TestPort
|
192
|
+
EM.connect TestHost, TestPort, PostInitError
|
193
|
+
}
|
194
|
+
}
|
195
|
+
EM.run {
|
196
|
+
EM.stop
|
197
|
+
}
|
198
|
+
assert !EM.reactor_running?
|
198
199
|
end
|
199
|
-
|
200
|
+
|
200
201
|
module BrsTestSrv
|
201
202
|
def receive_data data
|
202
203
|
$received << data
|
@@ -211,21 +212,74 @@ class TestBasic < Test::Unit::TestCase
|
|
211
212
|
close_connection_after_writing
|
212
213
|
end
|
213
214
|
end
|
214
|
-
|
215
|
+
|
215
216
|
# From ticket #50
|
216
217
|
def test_byte_range_send
|
217
218
|
$received = ''
|
218
219
|
$sent = (0..255).to_a.pack('C*')
|
219
220
|
EM::run {
|
220
|
-
|
221
221
|
EM::start_server TestHost, TestPort, BrsTestSrv
|
222
|
-
|
223
222
|
EM::connect TestHost, TestPort, BrsTestCli
|
224
|
-
|
223
|
+
|
225
224
|
EM::add_timer(0.5) { assert(false, 'test timed out'); EM.stop; Kernel.warn "test timed out!" }
|
226
225
|
}
|
227
226
|
assert_equal($sent, $received)
|
228
227
|
end
|
229
228
|
|
229
|
+
def test_bind_connect
|
230
|
+
local_ip = UDPSocket.open {|s| s.connect('google.com', 80); s.addr.last }
|
231
|
+
|
232
|
+
bind_port = rand(33333)+1025
|
233
|
+
|
234
|
+
test = self
|
235
|
+
EM.run do
|
236
|
+
EM.start_server(TestHost, TestPort, Module.new do
|
237
|
+
define_method :post_init do
|
238
|
+
begin
|
239
|
+
test.assert_equal bind_port, Socket.unpack_sockaddr_in(get_peername).first
|
240
|
+
test.assert_equal local_ip, Socket.unpack_sockaddr_in(get_peername).last
|
241
|
+
ensure
|
242
|
+
EM.stop_event_loop
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end)
|
246
|
+
EM.bind_connect local_ip, bind_port, TestHost, TestPort
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_reactor_thread?
|
251
|
+
assert !EM.reactor_thread?
|
252
|
+
EM.run { assert EM.reactor_thread?; EM.stop }
|
253
|
+
assert !EM.reactor_thread?
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_schedule_on_reactor_thread
|
257
|
+
x = false
|
258
|
+
EM.run do
|
259
|
+
EM.schedule { x = true }
|
260
|
+
EM.stop
|
261
|
+
end
|
262
|
+
assert x
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_schedule_from_thread
|
266
|
+
x = false
|
267
|
+
assert !x
|
268
|
+
EM.run do
|
269
|
+
Thread.new { EM.schedule { x = true } }.join
|
270
|
+
EM.stop
|
271
|
+
end
|
272
|
+
assert x
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_set_heartbeat_interval
|
276
|
+
interval = 0.5
|
277
|
+
EM.run {
|
278
|
+
EM.set_heartbeat_interval interval
|
279
|
+
$interval = EM.get_heartbeat_interval
|
280
|
+
EM.stop
|
281
|
+
}
|
282
|
+
assert_equal(interval, $interval)
|
283
|
+
end
|
230
284
|
end
|
231
285
|
|
@@ -0,0 +1,63 @@
|
|
1
|
+
$:.unshift "../lib"
|
2
|
+
require 'eventmachine'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class TestEventMachineChannel < Test::Unit::TestCase
|
6
|
+
def test_channel_subscribe
|
7
|
+
s = 0
|
8
|
+
EM.run do
|
9
|
+
c = EM::Channel.new
|
10
|
+
c.subscribe { |v| s = v; EM.stop }
|
11
|
+
c << 1
|
12
|
+
end
|
13
|
+
assert_equal 1, s
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_channel_unsubscribe
|
17
|
+
s = 0
|
18
|
+
EM.run do
|
19
|
+
c = EM::Channel.new
|
20
|
+
subscription = c.subscribe { |v| s = v }
|
21
|
+
c.unsubscribe(subscription)
|
22
|
+
c << 1
|
23
|
+
EM.next_tick { EM.stop }
|
24
|
+
end
|
25
|
+
assert_not_equal 1, s
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_channel_pop
|
29
|
+
s = 0
|
30
|
+
EM.run do
|
31
|
+
c = EM::Channel.new
|
32
|
+
c.pop{ |v| s = v }
|
33
|
+
c << 1
|
34
|
+
c << 2
|
35
|
+
EM.next_tick { EM.stop }
|
36
|
+
end
|
37
|
+
assert_equal 1, s
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_channel_reactor_thread_push
|
41
|
+
out = []
|
42
|
+
c = EM::Channel.new
|
43
|
+
c.subscribe { |v| out << v }
|
44
|
+
Thread.new { c.push(1,2,3) }.join
|
45
|
+
assert out.empty?
|
46
|
+
|
47
|
+
EM.run { EM.next_tick { EM.stop } }
|
48
|
+
|
49
|
+
assert_equal [1,2,3], out
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_channel_reactor_thread_callback
|
53
|
+
out = []
|
54
|
+
c = EM::Channel.new
|
55
|
+
Thread.new { c.subscribe { |v| out << v } }.join
|
56
|
+
c.push(1,2,3)
|
57
|
+
assert out.empty?
|
58
|
+
|
59
|
+
EM.run { EM.next_tick { EM.stop } }
|
60
|
+
|
61
|
+
assert_equal [1,2,3], out
|
62
|
+
end
|
63
|
+
end
|
@@ -29,10 +29,10 @@ class TestConnectionCount < Test::Unit::TestCase
|
|
29
29
|
|
30
30
|
def test_with_some_connections
|
31
31
|
EM.run {
|
32
|
-
EM.start_server("127.0.0.1", 9999, Server)
|
33
32
|
$initial = EM.connection_count
|
33
|
+
EM.start_server("127.0.0.1", 9999, Server)
|
34
|
+
$server_started = EM.connection_count
|
34
35
|
EM.next_tick{
|
35
|
-
$server_started = EM.connection_count
|
36
36
|
EM.connect("127.0.0.1", 9999, Client)
|
37
37
|
}
|
38
38
|
}
|
data/tests/test_epoll.rb
CHANGED
@@ -34,60 +34,61 @@ require 'test/unit'
|
|
34
34
|
|
35
35
|
class TestEpoll < Test::Unit::TestCase
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
37
|
+
module TestEchoServer
|
38
|
+
def receive_data data
|
39
|
+
send_data data
|
40
|
+
close_connection_after_writing
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module TestEchoClient
|
45
|
+
def connection_completed
|
46
|
+
send_data "ABCDE"
|
47
|
+
$max += 1
|
48
|
+
end
|
49
|
+
def receive_data data
|
50
|
+
raise "bad response" unless data == "ABCDE"
|
51
|
+
end
|
52
|
+
def unbind
|
53
|
+
$n -= 1
|
54
|
+
EM.stop if $n == 0
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
# We can set the rlimit/nofile of a process but we can only set it
|
60
|
+
# higher if we're running as root.
|
61
|
+
# On most systems, the default value is 1024.
|
62
|
+
# Java doesn't (currently) implement this.
|
63
|
+
def test_rlimit
|
64
|
+
unless RUBY_PLATFORM =~ /java/ or EM.set_descriptor_table_size >= 1024
|
65
|
+
a = EM.set_descriptor_table_size
|
66
|
+
assert( a <= 1024 )
|
67
|
+
a = EM.set_descriptor_table_size( 1024 )
|
68
|
+
assert( a == 1024 )
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Run a high-volume version of this test by kicking the number of connections
|
73
|
+
# up past 512. (Each connection uses two sockets, a client and a server.)
|
74
|
+
# (Will require running the test as root)
|
75
|
+
# This test exercises TCP clients and servers.
|
76
|
+
#
|
77
|
+
# XXX this test causes all sort of weird issues on OSX (when run as part of the suite)
|
78
|
+
def _test_descriptors
|
79
|
+
EM.epoll
|
80
|
+
s = EM.set_descriptor_table_size 60000
|
81
|
+
EM.run {
|
82
|
+
EM.start_server "127.0.0.1", 9800, TestEchoServer
|
83
|
+
$n = 0
|
84
|
+
$max = 0
|
85
|
+
100.times {
|
86
|
+
EM.connect("127.0.0.1", 9800, TestEchoClient) {$n += 1}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
assert_equal(0, $n)
|
90
|
+
assert_equal(100, $max)
|
91
|
+
end
|
91
92
|
|
92
93
|
def test_defer
|
93
94
|
n = 0
|
@@ -101,63 +102,61 @@ class TestEpoll < Test::Unit::TestCase
|
|
101
102
|
end unless RUBY_VERSION >= '1.9.0'
|
102
103
|
|
103
104
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
105
|
+
module TestDatagramServer
|
106
|
+
def receive_data dgm
|
107
|
+
$in = dgm
|
108
|
+
send_data "abcdefghij"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
module TestDatagramClient
|
112
|
+
def post_init
|
113
|
+
send_datagram "1234567890", "127.0.0.1", 9500
|
114
|
+
end
|
115
|
+
def receive_data dgm
|
116
|
+
$out = dgm
|
117
|
+
EM.stop
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_datagrams
|
122
|
+
$in = $out = ""
|
123
|
+
EM.epoll
|
124
|
+
EM.run {
|
125
|
+
EM.open_datagram_socket "127.0.0.1", 9500, TestDatagramServer
|
126
|
+
EM.open_datagram_socket "127.0.0.1", 0, TestDatagramClient
|
127
|
+
}
|
128
|
+
assert_equal( "1234567890", $in )
|
129
|
+
assert_equal( "abcdefghij", $out )
|
130
|
+
end
|
133
131
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
132
|
+
# XXX this test fails randomly..
|
133
|
+
def _test_unix_domain
|
134
|
+
fn = "/tmp/xxx.chain"
|
135
|
+
EM.epoll
|
136
|
+
s = EM.set_descriptor_table_size 60000
|
137
|
+
EM.run {
|
138
|
+
# The pure-Ruby version won't let us open the socket if the node already exists.
|
139
|
+
# Not sure, that actually may be correct and the compiled version is wrong.
|
140
|
+
# Pure Ruby also oddly won't let us make that many connections. This test used
|
141
|
+
# to run 100 times. Not sure where that lower connection-limit is coming from in
|
142
|
+
# pure Ruby.
|
143
|
+
# Let's not sweat the Unix-ness of the filename, since this test can't possibly
|
144
|
+
# work on Windows anyway.
|
145
|
+
#
|
146
|
+
File.unlink(fn) if File.exist?(fn)
|
147
|
+
EM.start_unix_domain_server fn, TestEchoServer
|
148
|
+
$n = 0
|
149
|
+
$max = 0
|
150
|
+
50.times {
|
151
|
+
EM.connect_unix_domain(fn, TestEchoClient) {$n += 1}
|
152
|
+
}
|
153
|
+
EM::add_timer(1) { $stderr.puts("test_unix_domain timed out!"); EM::stop }
|
154
|
+
}
|
155
|
+
assert_equal(0, $n)
|
156
|
+
assert_equal(50, $max)
|
157
|
+
ensure
|
158
|
+
File.unlink(fn) if File.exist?(fn)
|
159
|
+
end
|
161
160
|
|
162
161
|
end
|
163
162
|
|