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.
Files changed (116) hide show
  1. data/{docs/README → README} +21 -13
  2. data/Rakefile +5 -3
  3. data/docs/DEFERRABLES +0 -5
  4. data/docs/INSTALL +2 -4
  5. data/docs/LEGAL +1 -1
  6. data/docs/LIGHTWEIGHT_CONCURRENCY +0 -2
  7. data/docs/PURE_RUBY +0 -2
  8. data/docs/RELEASE_NOTES +0 -2
  9. data/docs/SMTP +0 -7
  10. data/docs/SPAWNED_PROCESSES +0 -4
  11. data/docs/TODO +0 -2
  12. data/eventmachine.gemspec +17 -8
  13. data/examples/ex_channel.rb +43 -0
  14. data/examples/ex_queue.rb +2 -0
  15. data/examples/helper.rb +2 -0
  16. data/ext/cmain.cpp +119 -20
  17. data/ext/cplusplus.cpp +15 -6
  18. data/ext/ed.cpp +303 -93
  19. data/ext/ed.h +49 -22
  20. data/ext/em.cpp +368 -42
  21. data/ext/em.h +43 -6
  22. data/ext/eventmachine.h +21 -8
  23. data/ext/eventmachine_cpp.h +1 -0
  24. data/ext/extconf.rb +4 -0
  25. data/ext/kb.cpp +1 -2
  26. data/ext/pipe.cpp +1 -3
  27. data/ext/project.h +21 -0
  28. data/ext/rubymain.cpp +232 -32
  29. data/ext/ssl.cpp +38 -1
  30. data/ext/ssl.h +5 -1
  31. data/java/src/com/rubyeventmachine/Application.java +7 -3
  32. data/java/src/com/rubyeventmachine/EmReactor.java +16 -1
  33. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +25 -3
  34. data/lib/{protocols → em}/buftok.rb +16 -5
  35. data/lib/em/callback.rb +26 -0
  36. data/lib/em/channel.rb +57 -0
  37. data/lib/em/connection.rb +505 -0
  38. data/lib/em/deferrable.rb +144 -165
  39. data/lib/em/file_watch.rb +54 -0
  40. data/lib/em/future.rb +24 -25
  41. data/lib/em/messages.rb +1 -1
  42. data/lib/em/process_watch.rb +44 -0
  43. data/lib/em/processes.rb +58 -52
  44. data/lib/em/protocols.rb +35 -0
  45. data/lib/em/protocols/header_and_content.rb +138 -0
  46. data/lib/em/protocols/httpclient.rb +263 -0
  47. data/lib/em/protocols/httpclient2.rb +582 -0
  48. data/lib/{protocols → em/protocols}/line_and_text.rb +2 -2
  49. data/lib/em/protocols/linetext2.rb +160 -0
  50. data/lib/{protocols → em/protocols}/memcache.rb +37 -7
  51. data/lib/em/protocols/object_protocol.rb +39 -0
  52. data/lib/em/protocols/postgres3.rb +247 -0
  53. data/lib/em/protocols/saslauth.rb +175 -0
  54. data/lib/em/protocols/smtpclient.rb +331 -0
  55. data/lib/em/protocols/smtpserver.rb +547 -0
  56. data/lib/em/protocols/stomp.rb +200 -0
  57. data/lib/{protocols → em/protocols}/tcptest.rb +21 -25
  58. data/lib/em/queue.rb +61 -0
  59. data/lib/em/spawnable.rb +53 -56
  60. data/lib/em/streamer.rb +92 -74
  61. data/lib/em/timers.rb +55 -0
  62. data/lib/em/version.rb +3 -0
  63. data/lib/eventmachine.rb +1008 -1298
  64. data/lib/evma.rb +1 -1
  65. data/lib/jeventmachine.rb +106 -101
  66. data/lib/pr_eventmachine.rb +47 -36
  67. data/tasks/project.rake +2 -1
  68. data/tests/client.crt +31 -0
  69. data/tests/client.key +51 -0
  70. data/tests/test_attach.rb +18 -0
  71. data/tests/test_basic.rb +108 -54
  72. data/tests/test_channel.rb +63 -0
  73. data/tests/test_connection_count.rb +2 -2
  74. data/tests/test_epoll.rb +109 -110
  75. data/tests/test_errors.rb +36 -36
  76. data/tests/test_exc.rb +22 -25
  77. data/tests/test_file_watch.rb +49 -0
  78. data/tests/test_futures.rb +77 -93
  79. data/tests/test_hc.rb +2 -2
  80. data/tests/test_httpclient.rb +55 -52
  81. data/tests/test_httpclient2.rb +110 -112
  82. data/tests/test_inactivity_timeout.rb +30 -0
  83. data/tests/test_kb.rb +8 -9
  84. data/tests/test_ltp2.rb +274 -277
  85. data/tests/test_next_tick.rb +91 -65
  86. data/tests/test_object_protocol.rb +37 -0
  87. data/tests/test_process_watch.rb +48 -0
  88. data/tests/test_processes.rb +56 -23
  89. data/tests/test_proxy_connection.rb +92 -0
  90. data/tests/test_pure.rb +1 -5
  91. data/tests/test_queue.rb +44 -0
  92. data/tests/test_running.rb +9 -14
  93. data/tests/test_sasl.rb +32 -34
  94. data/tests/test_send_file.rb +175 -176
  95. data/tests/test_servers.rb +37 -41
  96. data/tests/test_smtpserver.rb +47 -55
  97. data/tests/test_spawn.rb +284 -291
  98. data/tests/test_ssl_args.rb +1 -1
  99. data/tests/test_ssl_methods.rb +1 -1
  100. data/tests/test_ssl_verify.rb +82 -0
  101. data/tests/test_timers.rb +81 -88
  102. data/tests/test_ud.rb +0 -7
  103. data/tests/testem.rb +1 -1
  104. metadata +52 -36
  105. data/lib/em/eventable.rb +0 -39
  106. data/lib/eventmachine_version.rb +0 -31
  107. data/lib/protocols/header_and_content.rb +0 -129
  108. data/lib/protocols/httpcli2.rb +0 -803
  109. data/lib/protocols/httpclient.rb +0 -270
  110. data/lib/protocols/linetext2.rb +0 -161
  111. data/lib/protocols/postgres.rb +0 -261
  112. data/lib/protocols/saslauth.rb +0 -179
  113. data/lib/protocols/smtpclient.rb +0 -308
  114. data/lib/protocols/smtpserver.rb +0 -556
  115. data/lib/protocols/stomp.rb +0 -153
  116. data/tests/test_eventables.rb +0 -77
@@ -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
@@ -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
- em_lib = (ENV["EVENTMACHINE_LIBRARY"] || $eventmachine_library || :xxx).to_sym
46
-
47
- # Running from test runner, under jruby.
48
- if RUBY_PLATFORM == 'java'
49
- unless em_lib == :pure_ruby
50
- assert_equal( :java, lt )
51
- return
52
- end
53
- end
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
- # Running from jruby as a standalone test.
64
- if RUBY_PLATFORM == 'java'
65
- assert_equal( :java, lt )
66
- else
67
- assert_equal( :extension, lt )
68
- end
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
- a = nil
120
- EM.run_block { a = "Worked" }
121
- assert a
122
- assert !EM.reactor_running?
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
- def initialize *args
140
- super
141
- end
142
- def connection_completed
143
- close_connection_after_writing
144
- end
145
- def unbind
146
- raise "Blooey"
147
- end
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
- assert_raises( RuntimeError ) {
152
- EM.run {
153
- EM.start_server TestHost, TestPort
154
- EM.connect TestHost, TestPort, UnbindError
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
- def post_init
181
- aaa bbb # should produce a Ruby exception
182
- end
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
- assert_raises( EventMachine::ConnectionNotBound ) {
188
- EM.run {
189
- EM::Timer.new(1) {EM.stop}
190
- EM.start_server TestHost, TestPort
191
- EM.connect TestHost, TestPort, PostInitError
192
- }
193
- }
194
- EM.run {
195
- EM.stop
196
- }
197
- assert !EM.reactor_running?
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
  }
@@ -34,60 +34,61 @@ require 'test/unit'
34
34
 
35
35
  class TestEpoll < Test::Unit::TestCase
36
36
 
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
- def test_descriptors
78
- EM.epoll
79
- s = EM.set_descriptor_table_size 60000
80
- EM.run {
81
- EM.start_server "127.0.0.1", 9800, TestEchoServer
82
- $n = 0
83
- $max = 0
84
- 100.times {
85
- EM.connect("127.0.0.1", 9800, TestEchoClient) {$n += 1}
86
- }
87
- }
88
- assert_equal(0, $n)
89
- assert_equal(100, $max)
90
- end
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
- module TestDatagramServer
105
- def receive_data dgm
106
- $in = dgm
107
- send_data "abcdefghij"
108
- end
109
- end
110
- module TestDatagramClient
111
- def post_init
112
- send_datagram "1234567890", "127.0.0.1", 9500
113
- end
114
- def receive_data dgm
115
- $out = dgm
116
- EM.stop
117
- end
118
- end
119
-
120
- def test_datagrams
121
- $in = $out = ""
122
- EM.epoll
123
- EM.run {
124
- EM.open_datagram_socket "127.0.0.1", 9500, TestDatagramServer
125
- EM.open_datagram_socket "127.0.0.1", 0, TestDatagramClient
126
- }
127
- assert_equal( "1234567890", $in )
128
- assert_equal( "abcdefghij", $out )
129
- end
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
- def test_unix_domain
135
- fn = "/tmp/xxx.chain"
136
- EM.epoll
137
- s = EM.set_descriptor_table_size 60000
138
- EM.run {
139
- # The pure-Ruby version won't let us open the socket if the node already exists.
140
- # Not sure, that actually may be correct and the compiled version is wrong.
141
- # Pure Ruby also oddly won't let us make that many connections. This test used
142
- # to run 100 times. Not sure where that lower connection-limit is coming from in
143
- # pure Ruby.
144
- # Let's not sweat the Unix-ness of the filename, since this test can't possibly
145
- # work on Windows anyway.
146
- #
147
- File.unlink(fn) if File.exist?(fn)
148
- EM.start_unix_domain_server fn, TestEchoServer
149
- $n = 0
150
- $max = 0
151
- 50.times {
152
- EM.connect_unix_domain(fn, TestEchoClient) {$n += 1}
153
- }
154
- EM::add_timer(1) { $stderr.puts("test_unix_domain timed out!"); EM::stop }
155
- }
156
- assert_equal(0, $n)
157
- assert_equal(50, $max)
158
- ensure
159
- File.unlink(fn) if File.exist?(fn)
160
- end
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