eventmachine 0.12.0-i386-mswin32

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.
Files changed (104) hide show
  1. data/COPYING +60 -0
  2. data/DEFERRABLES +138 -0
  3. data/EPOLL +141 -0
  4. data/GNU +281 -0
  5. data/KEYBOARD +38 -0
  6. data/LEGAL +25 -0
  7. data/LIGHTWEIGHT_CONCURRENCY +72 -0
  8. data/PURE_RUBY +77 -0
  9. data/README +74 -0
  10. data/RELEASE_NOTES +96 -0
  11. data/SMTP +9 -0
  12. data/SPAWNED_PROCESSES +93 -0
  13. data/TODO +10 -0
  14. data/ext/Makefile +180 -0
  15. data/ext/binder.cpp +126 -0
  16. data/ext/binder.h +48 -0
  17. data/ext/cmain.cpp +527 -0
  18. data/ext/cplusplus.cpp +172 -0
  19. data/ext/ed.cpp +1442 -0
  20. data/ext/ed.h +351 -0
  21. data/ext/em.cpp +1781 -0
  22. data/ext/em.h +167 -0
  23. data/ext/emwin.cpp +300 -0
  24. data/ext/emwin.h +94 -0
  25. data/ext/epoll.cpp +26 -0
  26. data/ext/epoll.h +25 -0
  27. data/ext/eventmachine.h +83 -0
  28. data/ext/eventmachine_cpp.h +94 -0
  29. data/ext/extconf.rb +203 -0
  30. data/ext/files.cpp +94 -0
  31. data/ext/files.h +65 -0
  32. data/ext/kb.cpp +368 -0
  33. data/ext/mkmf.log +129 -0
  34. data/ext/page.cpp +107 -0
  35. data/ext/page.h +51 -0
  36. data/ext/pipe.cpp +327 -0
  37. data/ext/project.h +119 -0
  38. data/ext/rubyeventmachine-i386-mswin32.def +2 -0
  39. data/ext/rubyeventmachine-i386-mswin32.exp +0 -0
  40. data/ext/rubyeventmachine-i386-mswin32.lib +0 -0
  41. data/ext/rubyeventmachine-i386-mswin32.pdb +0 -0
  42. data/ext/rubyeventmachine.so +0 -0
  43. data/ext/rubymain.cpp +630 -0
  44. data/ext/sigs.cpp +89 -0
  45. data/ext/sigs.h +32 -0
  46. data/ext/ssl.cpp +408 -0
  47. data/ext/ssl.h +86 -0
  48. data/ext/vc60.pdb +0 -0
  49. data/lib/em/deferrable.rb +208 -0
  50. data/lib/em/eventable.rb +39 -0
  51. data/lib/em/future.rb +62 -0
  52. data/lib/em/messages.rb +66 -0
  53. data/lib/em/processes.rb +68 -0
  54. data/lib/em/spawnable.rb +88 -0
  55. data/lib/em/streamer.rb +112 -0
  56. data/lib/eventmachine.rb +1621 -0
  57. data/lib/eventmachine_version.rb +31 -0
  58. data/lib/evma.rb +32 -0
  59. data/lib/evma/callback.rb +32 -0
  60. data/lib/evma/container.rb +75 -0
  61. data/lib/evma/factory.rb +77 -0
  62. data/lib/evma/protocol.rb +87 -0
  63. data/lib/evma/reactor.rb +48 -0
  64. data/lib/jeventmachine.rb +106 -0
  65. data/lib/pr_eventmachine.rb +1011 -0
  66. data/lib/protocols/buftok.rb +127 -0
  67. data/lib/protocols/header_and_content.rb +123 -0
  68. data/lib/protocols/httpcli2.rb +784 -0
  69. data/lib/protocols/httpclient.rb +253 -0
  70. data/lib/protocols/line_and_text.rb +122 -0
  71. data/lib/protocols/linetext2.rb +145 -0
  72. data/lib/protocols/saslauth.rb +179 -0
  73. data/lib/protocols/smtpclient.rb +308 -0
  74. data/lib/protocols/smtpserver.rb +543 -0
  75. data/lib/protocols/stomp.rb +127 -0
  76. data/lib/protocols/tcptest.rb +57 -0
  77. data/lib/rubyeventmachine.so +0 -0
  78. data/tests/test_basic.rb +142 -0
  79. data/tests/test_defer.rb +63 -0
  80. data/tests/test_epoll.rb +168 -0
  81. data/tests/test_errors.rb +82 -0
  82. data/tests/test_eventables.rb +78 -0
  83. data/tests/test_exc.rb +58 -0
  84. data/tests/test_futures.rb +214 -0
  85. data/tests/test_hc.rb +221 -0
  86. data/tests/test_httpclient.rb +194 -0
  87. data/tests/test_httpclient2.rb +133 -0
  88. data/tests/test_kb.rb +61 -0
  89. data/tests/test_ltp.rb +190 -0
  90. data/tests/test_ltp2.rb +261 -0
  91. data/tests/test_next_tick.rb +58 -0
  92. data/tests/test_processes.rb +56 -0
  93. data/tests/test_pure.rb +128 -0
  94. data/tests/test_running.rb +47 -0
  95. data/tests/test_sasl.rb +73 -0
  96. data/tests/test_send_file.rb +238 -0
  97. data/tests/test_servers.rb +90 -0
  98. data/tests/test_smtpclient.rb +81 -0
  99. data/tests/test_smtpserver.rb +93 -0
  100. data/tests/test_spawn.rb +329 -0
  101. data/tests/test_timers.rb +138 -0
  102. data/tests/test_ud.rb +43 -0
  103. data/tests/testem.rb +5 -0
  104. metadata +170 -0
@@ -0,0 +1,47 @@
1
+ # $Id: test_running.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+
27
+ $:.unshift "../lib"
28
+ require 'eventmachine'
29
+ require 'test/unit'
30
+
31
+ class TestRunning < Test::Unit::TestCase
32
+ def setup
33
+ end
34
+ def teardown
35
+ end
36
+
37
+ def test_running
38
+ assert_equal( false, EM::reactor_running? )
39
+ r = false
40
+ EM.run {
41
+ r = EM::reactor_running?
42
+ EM.stop
43
+ }
44
+ assert_equal( true, r )
45
+ end
46
+ end
47
+
@@ -0,0 +1,73 @@
1
+ # $Id: test_sasl.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+
27
+ $:.unshift "../lib"
28
+ require 'eventmachine'
29
+ require 'test/unit'
30
+
31
+
32
+ class TestSASL < Test::Unit::TestCase
33
+
34
+ # SASL authentication is usually done with UNIX-domain sockets, but
35
+ # we'll use TCP so this test will work on Windows. As far as the
36
+ # protocol handlers are concerned, there's no difference.
37
+
38
+
39
+ Host,Port = "127.0.0.1",9560
40
+ TestUser,TestPsw = "someone", "password"
41
+
42
+ class SaslServer < EM::Connection
43
+ include EM::Protocols::SASLauth
44
+ def validate usr, psw, sys, realm
45
+ usr == TestUser and psw == TestPsw
46
+ end
47
+ end
48
+
49
+ class SaslClient < EM::Connection
50
+ include EM::Protocols::SASLauthclient
51
+ end
52
+
53
+ def test_sasl
54
+ resp = nil
55
+ EM.run {
56
+ EM.start_server( Host, Port, SaslServer )
57
+
58
+ c = EM.connect( Host, Port, SaslClient )
59
+ d = c.validate?( TestUser, TestPsw )
60
+ d.callback {
61
+ resp = true
62
+ EM.stop
63
+ }
64
+ d.errback {
65
+ resp = false
66
+ EM.stop
67
+ }
68
+ }
69
+ assert_equal( true, resp )
70
+ end
71
+
72
+ end
73
+
@@ -0,0 +1,238 @@
1
+ # $Id: test_send_file.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+
27
+ $:.unshift "../lib"
28
+ require 'eventmachine'
29
+ require 'socket'
30
+ require 'test/unit'
31
+
32
+ class TestSendFile < Test::Unit::TestCase
33
+
34
+ module TestModule
35
+ def post_init
36
+ send_file_data TestFilename
37
+ close_connection_after_writing
38
+ end
39
+ end
40
+
41
+ TestHost = "0.0.0.0"
42
+ TestPort = 9055
43
+ TestFilename = "./xxxxxx"
44
+
45
+ def setup
46
+ end
47
+
48
+ def teardown
49
+ File.unlink( TestFilename ) if File.exist?( TestFilename )
50
+ end
51
+
52
+ def test_send_file
53
+ File.open( TestFilename, "w" ) {|f|
54
+ f << ("A" * 5000)
55
+ }
56
+
57
+ data = nil
58
+
59
+ EM.run {
60
+ EM.start_server TestHost, TestPort, TestModule
61
+ EM.add_timer(2) {EM.stop} # avoid hanging in case of error
62
+ EM.defer proc {
63
+ t = TCPSocket.new TestHost, TestPort
64
+ data = t.read
65
+ }, proc {
66
+ EM.stop
67
+ }
68
+ }
69
+
70
+ assert_equal( "A" * 5000, data )
71
+ File.unlink TestFilename
72
+ end
73
+
74
+ # EventMachine::Connection#send_file_data has a strict upper limit on the filesize it will work with.
75
+ def test_send_large_file
76
+ File.open( TestFilename, "w" ) {|f|
77
+ f << ("A" * 1000000)
78
+ }
79
+
80
+ data = nil
81
+
82
+ assert_raise(RuntimeError) {
83
+ EM.run {
84
+ EM.start_server TestHost, TestPort, TestModule
85
+ EM.add_timer(2) {EM.stop} # avoid hanging in case of error
86
+ EM.defer proc {
87
+ t = TCPSocket.new TestHost, TestPort
88
+ data = t.read
89
+ }, proc {
90
+ EM.stop
91
+ }
92
+ }
93
+ }
94
+
95
+ File.unlink TestFilename
96
+ end
97
+
98
+
99
+ module StreamTestModule
100
+ def post_init
101
+ EM::Deferrable.future( stream_file_data(TestFilename)) {
102
+ close_connection_after_writing
103
+ }
104
+ end
105
+ end
106
+
107
+ module ChunkStreamTestModule
108
+ def post_init
109
+ EM::Deferrable.future( stream_file_data(TestFilename, :http_chunks=>true)) {
110
+ close_connection_after_writing
111
+ }
112
+ end
113
+ end
114
+
115
+ def test_stream_file_data
116
+ File.open( TestFilename, "w" ) {|f|
117
+ f << ("A" * 1000)
118
+ }
119
+
120
+ data = nil
121
+
122
+ EM.run {
123
+ EM.start_server TestHost, TestPort, StreamTestModule
124
+ EM.add_timer(2) {EM.stop} # avoid hanging in case of error
125
+ EM.defer proc {
126
+ t = TCPSocket.new TestHost, TestPort
127
+ data = t.read
128
+ }, proc {
129
+ EM.stop
130
+ }
131
+ }
132
+
133
+ assert_equal( "A" * 1000, data )
134
+
135
+ File.unlink TestFilename
136
+ end
137
+
138
+ def test_stream_chunked_file_data
139
+ File.open( TestFilename, "w" ) {|f|
140
+ f << ("A" * 1000)
141
+ }
142
+
143
+ data = nil
144
+
145
+ EM.run {
146
+ EM.start_server TestHost, TestPort, ChunkStreamTestModule
147
+ EM.add_timer(2) {EM.stop} # avoid hanging in case of error
148
+ EM.defer proc {
149
+ t = TCPSocket.new TestHost, TestPort
150
+ data = t.read
151
+ }, proc {
152
+ EM.stop
153
+ }
154
+ }
155
+
156
+ assert_equal( "3e8\r\n#{"A" * 1000}\r\n0\r\n\r\n", data )
157
+
158
+ File.unlink TestFilename
159
+ end
160
+
161
+ module BadFileTestModule
162
+ def post_init
163
+ de = stream_file_data( TestFilename+"..." )
164
+ de.errback {|msg|
165
+ send_data msg
166
+ close_connection_after_writing
167
+ }
168
+ end
169
+ end
170
+ def test_stream_bad_file
171
+ data = nil
172
+ EM.run {
173
+ EM.start_server TestHost, TestPort, BadFileTestModule
174
+ EM.add_timer(2) {EM.stop} # avoid hanging in case of error
175
+ EM.defer proc {
176
+ t = TCPSocket.new TestHost, TestPort
177
+ data = t.read
178
+ }, proc {
179
+ EM.stop
180
+ }
181
+ }
182
+
183
+ assert_equal( "file not found", data )
184
+ end
185
+
186
+ def test_stream_large_file_data
187
+ File.open( TestFilename, "w" ) {|f|
188
+ f << ("A" * 10000)
189
+ }
190
+
191
+ data = nil
192
+
193
+ EM.run {
194
+ EM.start_server TestHost, TestPort, StreamTestModule
195
+ EM.add_timer(2) {EM.stop} # avoid hanging in case of error
196
+ EM.defer proc {
197
+ t = TCPSocket.new TestHost, TestPort
198
+ data = t.read
199
+ }, proc {
200
+ EM.stop
201
+ }
202
+ }
203
+
204
+ assert_equal( "A" * 10000, data )
205
+
206
+ File.unlink TestFilename
207
+ end
208
+
209
+ def test_stream_large_chunked_file_data
210
+ File.open( TestFilename, "w" ) {|f|
211
+ f << ("A" * 100000)
212
+ }
213
+
214
+ data = nil
215
+
216
+ EM.run {
217
+ EM.start_server TestHost, TestPort, ChunkStreamTestModule
218
+ EM.add_timer(2) {EM.stop} # avoid hanging in case of error
219
+ EM.defer proc {
220
+ t = TCPSocket.new TestHost, TestPort
221
+ data = t.read
222
+ }, proc {
223
+ EM.stop
224
+ }
225
+ }
226
+
227
+ expected = [
228
+ "4000\r\n#{"A" * 16384}\r\n" * 6,
229
+ "6a0\r\n#{"A" * 0x6a0}\r\n",
230
+ "0\r\n\r\n"
231
+ ].join
232
+ assert_equal( expected, data )
233
+
234
+ File.unlink TestFilename
235
+ end
236
+
237
+ end
238
+
@@ -0,0 +1,90 @@
1
+ # $Id: test_servers.rb 668 2008-01-04 23:00:34Z blackhedd $
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+
27
+ $:.unshift "../lib"
28
+ require 'eventmachine'
29
+ require 'socket'
30
+ require 'test/unit'
31
+
32
+
33
+ class TestServers < Test::Unit::TestCase
34
+
35
+ Host = "127.0.0.1"
36
+ Port = 9550
37
+
38
+ def setup
39
+ end
40
+
41
+ def teardown
42
+ end
43
+
44
+
45
+ class TestStopServer < EM::Connection
46
+ def initialize *args
47
+ super
48
+ end
49
+ def post_init
50
+ # TODO,sucks that this isn't OOPy enough.
51
+ EM.stop_server @server_instance
52
+ end
53
+ end
54
+ def run_test_stop_server
55
+ succeed = false
56
+ err = false
57
+ EM.run {
58
+ sig = EM.start_server(Host, Port)
59
+ EM.defer proc {
60
+ if TCPSocket.new Host, Port
61
+ succeed = true
62
+ end
63
+ }, proc {
64
+ EM.stop_server sig
65
+ EM.defer proc {
66
+ # Wait for the acceptor to die, otherwise
67
+ # we'll probably get a conn-reset instead
68
+ # of a conn-refused.
69
+ sleep 0.1
70
+ begin
71
+ TCPSocket.new Host, Port
72
+ rescue
73
+ err = $!
74
+ end
75
+ }, proc {
76
+ EM.stop
77
+ }
78
+ }
79
+ }
80
+ assert_equal( true, succeed )
81
+ assert_equal( Errno::ECONNREFUSED, err.class )
82
+ end
83
+ def test_stop_server
84
+ 5.times {run_test_stop_server}
85
+ end
86
+
87
+
88
+ end
89
+
90
+