eventmachine 0.12.8 → 0.12.10

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 (66) hide show
  1. data/.gitignore +2 -1
  2. data/Rakefile +155 -45
  3. data/eventmachine.gemspec +4 -5
  4. data/ext/binder.cpp +13 -14
  5. data/ext/binder.h +5 -7
  6. data/ext/cmain.cpp +184 -42
  7. data/ext/cplusplus.cpp +20 -20
  8. data/ext/ed.cpp +242 -81
  9. data/ext/ed.h +39 -22
  10. data/ext/em.cpp +127 -108
  11. data/ext/em.h +27 -18
  12. data/ext/emwin.cpp +3 -3
  13. data/ext/eventmachine.h +49 -38
  14. data/ext/eventmachine_cpp.h +4 -4
  15. data/ext/extconf.rb +28 -13
  16. data/ext/fastfilereader/extconf.rb +11 -5
  17. data/ext/project.h +12 -1
  18. data/ext/rubymain.cpp +222 -103
  19. data/ext/ssl.cpp +3 -3
  20. data/ext/ssl.h +2 -2
  21. data/java/src/com/rubyeventmachine/EmReactor.java +396 -249
  22. data/java/src/com/rubyeventmachine/EventableChannel.java +16 -4
  23. data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +23 -5
  24. data/java/src/com/rubyeventmachine/EventableSocketChannel.java +181 -61
  25. data/java/src/com/rubyeventmachine/{Application.java → application/Application.java} +25 -31
  26. data/java/src/com/rubyeventmachine/{Connection.java → application/Connection.java} +2 -2
  27. data/java/src/com/rubyeventmachine/{ConnectionFactory.java → application/ConnectionFactory.java} +1 -1
  28. data/java/src/com/rubyeventmachine/{DefaultConnectionFactory.java → application/DefaultConnectionFactory.java} +2 -2
  29. data/java/src/com/rubyeventmachine/{PeriodicTimer.java → application/PeriodicTimer.java} +1 -1
  30. data/java/src/com/rubyeventmachine/{Timer.java → application/Timer.java} +1 -1
  31. data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +1 -0
  32. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +4 -2
  33. data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +1 -1
  34. data/java/src/com/rubyeventmachine/tests/TestServers.java +1 -0
  35. data/java/src/com/rubyeventmachine/tests/TestTimers.java +1 -0
  36. data/lib/em/connection.rb +71 -12
  37. data/lib/em/deferrable.rb +5 -0
  38. data/lib/em/protocols.rb +1 -0
  39. data/lib/em/protocols/httpclient2.rb +8 -0
  40. data/lib/em/protocols/line_and_text.rb +0 -1
  41. data/lib/em/protocols/linetext2.rb +1 -0
  42. data/lib/em/protocols/object_protocol.rb +8 -2
  43. data/lib/em/protocols/smtpclient.rb +42 -16
  44. data/lib/em/protocols/socks4.rb +66 -0
  45. data/lib/em/queue.rb +1 -1
  46. data/lib/em/timers.rb +2 -1
  47. data/lib/em/version.rb +1 -1
  48. data/lib/eventmachine.rb +125 -169
  49. data/lib/jeventmachine.rb +124 -9
  50. data/tasks/{cpp.rake → cpp.rake_example} +0 -0
  51. data/tests/test_attach.rb +29 -4
  52. data/tests/test_basic.rb +1 -2
  53. data/tests/test_connection_count.rb +10 -20
  54. data/tests/test_epoll.rb +0 -2
  55. data/tests/test_get_sock_opt.rb +30 -0
  56. data/tests/test_httpclient2.rb +3 -3
  57. data/tests/test_inactivity_timeout.rb +21 -1
  58. data/tests/test_ltp.rb +0 -6
  59. data/tests/test_next_tick.rb +0 -2
  60. data/tests/test_pause.rb +70 -0
  61. data/tests/test_pending_connect_timeout.rb +48 -0
  62. data/tests/test_ssl_args.rb +16 -5
  63. data/tests/test_timers.rb +22 -1
  64. metadata +14 -12
  65. data/tasks/project.rake +0 -79
  66. data/tasks/tests.rake +0 -193
@@ -0,0 +1,48 @@
1
+ $:.unshift "../lib"
2
+ require 'eventmachine'
3
+ require 'test/unit'
4
+
5
+ class TestPendingConnectTimeout < Test::Unit::TestCase
6
+
7
+ def test_default
8
+ $timeout = nil
9
+ EM.run {
10
+ c = EM.connect("127.0.0.1", 54321)
11
+ $timeout = c.pending_connect_timeout
12
+ EM.stop
13
+ }
14
+
15
+ assert_equal(20.0, $timeout)
16
+ end
17
+
18
+ def test_set_and_get
19
+ $timeout = nil
20
+ EM.run {
21
+ c = EM.connect("1.2.3.4", 54321)
22
+ c.pending_connect_timeout = 2.5
23
+ $timeout = c.pending_connect_timeout
24
+ EM.stop
25
+ }
26
+
27
+ assert_equal(2.5, $timeout)
28
+ end
29
+
30
+ module TimeoutHandler
31
+ def unbind
32
+ EM.stop
33
+ end
34
+ end
35
+
36
+ def test_for_real
37
+ $timeout = nil
38
+ EM.run {
39
+ EM.heartbeat_interval = 0.1
40
+ $start = Time.now
41
+ c = EM.connect("1.2.3.4", 54321, TimeoutHandler)
42
+ c.pending_connect_timeout = 5
43
+ }
44
+
45
+ assert_in_delta(5, (Time.now - $start), 0.3)
46
+ end
47
+
48
+ end
@@ -9,18 +9,29 @@ module EventMachine
9
9
  class <<self
10
10
  alias set_tls_parms_old set_tls_parms
11
11
  alias start_tls_old start_tls
12
- def set_tls_parms *args; end
13
- def start_tls *args; end
12
+ begin
13
+ old, $VERBOSE = $VERBOSE, nil
14
+ def set_tls_parms *args; end
15
+ def start_tls *args; end
16
+ ensure
17
+ $VERBOSE = old
18
+ end
14
19
  end
15
20
  end
16
-
21
+
17
22
  def self._clear_mocks
18
23
  class <<self
19
- alias set_tls_parms set_tls_parms_old
20
- alias start_tls start_tls_old
24
+ begin
25
+ old, $VERBOSE = $VERBOSE, nil
26
+ alias set_tls_parms set_tls_parms_old
27
+ alias start_tls start_tls_old
28
+ ensure
29
+ $VERBOSE = old
30
+ end
21
31
  end
22
32
  end
23
33
  end
34
+
24
35
 
25
36
 
26
37
  class TestSslArgs < Test::Unit::TestCase
@@ -74,6 +74,17 @@ class TestTimers < Test::Unit::TestCase
74
74
  assert( x == 4 )
75
75
  end
76
76
 
77
+ def test_add_periodic_timer
78
+ x = 0
79
+ EM.run {
80
+ t = EM.add_periodic_timer(0.1) do
81
+ x += 1
82
+ EM.stop if x == 4
83
+ end
84
+ assert t.respond_to?(:cancel)
85
+ }
86
+ end
87
+
77
88
  def test_periodic_timer_cancel
78
89
  x = 0
79
90
  EventMachine.run {
@@ -84,6 +95,16 @@ class TestTimers < Test::Unit::TestCase
84
95
  assert( x == 0 )
85
96
  end
86
97
 
98
+ def test_add_periodic_timer_cancel
99
+ x = 0
100
+ EventMachine.run {
101
+ pt = EM.add_periodic_timer(0.25) { x += 1 }
102
+ EM.cancel_timer(pt)
103
+ EM.add_timer(0.5) { EM.stop }
104
+ }
105
+ assert( x == 0 )
106
+ end
107
+
87
108
  def test_periodic_timer_self_cancel
88
109
  x = 0
89
110
  EventMachine.run {
@@ -104,7 +125,7 @@ class TestTimers < Test::Unit::TestCase
104
125
  #
105
126
  def test_timer_change_max_outstanding
106
127
  ten_thousand_timers = proc {
107
- 10000.times {
128
+ 10001.times {
108
129
  EM.add_timer(5) {}
109
130
  }
110
131
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventmachine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.8
4
+ version: 0.12.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Cianfrocca
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-22 00:00:00 -07:00
12
+ date: 2009-10-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -88,17 +88,17 @@ files:
88
88
  - ext/ssl.h
89
89
  - java/.classpath
90
90
  - java/.project
91
- - java/src/com/rubyeventmachine/Application.java
92
- - java/src/com/rubyeventmachine/Connection.java
93
- - java/src/com/rubyeventmachine/ConnectionFactory.java
94
- - java/src/com/rubyeventmachine/DefaultConnectionFactory.java
95
91
  - java/src/com/rubyeventmachine/EmReactor.java
96
92
  - java/src/com/rubyeventmachine/EmReactorException.java
97
93
  - java/src/com/rubyeventmachine/EventableChannel.java
98
94
  - java/src/com/rubyeventmachine/EventableDatagramChannel.java
99
95
  - java/src/com/rubyeventmachine/EventableSocketChannel.java
100
- - java/src/com/rubyeventmachine/PeriodicTimer.java
101
- - java/src/com/rubyeventmachine/Timer.java
96
+ - java/src/com/rubyeventmachine/application/Application.java
97
+ - java/src/com/rubyeventmachine/application/Connection.java
98
+ - java/src/com/rubyeventmachine/application/ConnectionFactory.java
99
+ - java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java
100
+ - java/src/com/rubyeventmachine/application/PeriodicTimer.java
101
+ - java/src/com/rubyeventmachine/application/Timer.java
102
102
  - java/src/com/rubyeventmachine/tests/ApplicationTest.java
103
103
  - java/src/com/rubyeventmachine/tests/ConnectTest.java
104
104
  - java/src/com/rubyeventmachine/tests/EMTest.java
@@ -127,6 +127,7 @@ files:
127
127
  - lib/em/protocols/saslauth.rb
128
128
  - lib/em/protocols/smtpclient.rb
129
129
  - lib/em/protocols/smtpserver.rb
130
+ - lib/em/protocols/socks4.rb
130
131
  - lib/em/protocols/stomp.rb
131
132
  - lib/em/protocols/tcptest.rb
132
133
  - lib/em/queue.rb
@@ -144,9 +145,7 @@ files:
144
145
  - lib/jeventmachine.rb
145
146
  - lib/pr_eventmachine.rb
146
147
  - setup.rb
147
- - tasks/cpp.rake
148
- - tasks/project.rake
149
- - tasks/tests.rake
148
+ - tasks/cpp.rake_example
150
149
  - tests/client.crt
151
150
  - tests/client.key
152
151
  - tests/test_attach.rb
@@ -160,6 +159,7 @@ files:
160
159
  - tests/test_exc.rb
161
160
  - tests/test_file_watch.rb
162
161
  - tests/test_futures.rb
162
+ - tests/test_get_sock_opt.rb
163
163
  - tests/test_handler_check.rb
164
164
  - tests/test_hc.rb
165
165
  - tests/test_httpclient.rb
@@ -170,6 +170,8 @@ files:
170
170
  - tests/test_ltp2.rb
171
171
  - tests/test_next_tick.rb
172
172
  - tests/test_object_protocol.rb
173
+ - tests/test_pause.rb
174
+ - tests/test_pending_connect_timeout.rb
173
175
  - tests/test_process_watch.rb
174
176
  - tests/test_processes.rb
175
177
  - tests/test_proxy_connection.rb
@@ -227,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
229
  requirements: []
228
230
 
229
231
  rubyforge_project: eventmachine
230
- rubygems_version: 1.3.3
232
+ rubygems_version: 1.3.4
231
233
  signing_key:
232
234
  specification_version: 3
233
235
  summary: Ruby/EventMachine library
@@ -1,79 +0,0 @@
1
- require 'rake/gempackagetask'
2
- require 'rake/rdoctask'
3
- require 'rake/clean'
4
-
5
- # monkey bitchin' for windows stuffs...
6
- module FileUtils
7
- # If any of these methods ever clobber, try removing them.
8
- # Hopefully they'll do something semantically similar.
9
- abort "Err: #{__FILE__}:#{__LINE__} monkey patch windows? clobbers!" unless instance_methods.grep(/windows\?/).empty?
10
- abort "Err: #{__FILE__}:#{__LINE__} monkey patch sudo clobbers!" unless instance_methods.grep(/sudo/).empty?
11
- abort "Err: #{__FILE__}:#{__LINE__} monkey patch gem_cmd clobbers!" unless instance_methods.grep(/gem_cmd/).empty?
12
- def windows?; RUBY_PLATFORM =~ /mswin|mingw/; end
13
- def sudo(cmd)
14
- if windows? || (require 'etc'; Etc.getpwuid.uid == 0)
15
- sh cmd
16
- else
17
- sh "sudo #{cmd}"
18
- end
19
- end
20
- def gem_cmd(action, name, *args)
21
- rb = Gem.ruby rescue nil
22
- rb ||= (require 'rbconfig'; File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']))
23
- sudo "#{rb} -r rubygems -e 'require %{rubygems/gem_runner}; Gem::GemRunner.new.run(%w{#{action} #{name} #{args.join(' ')}})'"
24
- end
25
- end
26
-
27
-
28
- # Setup our packaging tasks, we're just jacking the builtins.
29
- Rake::GemPackageTask.new(Spec) do |pkg|
30
- pkg.need_tar, pkg.need_tar_gz, pkg.need_zip = true, true, true if Package
31
- pkg.gem_spec = Spec
32
- end
33
- Rake::Task[:clean].enhance [:clobber_package]
34
-
35
- # Only generate rdoc if the spec says so, again, jack the builtins.
36
- if Spec.has_rdoc
37
- Rake::RDocTask.new do |rd|
38
- rd.title = Spec.name
39
- rd.rdoc_dir = 'rdoc'
40
- rd.main = "README"
41
- rd.rdoc_files.include("lib/**/*.rb", *Spec.extra_rdoc_files)
42
- rd.rdoc_files.exclude(*%w(lib/em/version lib/emva lib/evma/ lib/pr_eventmachine lib/jeventmachine))
43
- end
44
- Rake::Task[:clean].enhance [:clobber_rdoc]
45
-
46
- desc 'Generate and open documentation'
47
- task :docs => :rdoc do
48
- case RUBY_PLATFORM
49
- when /darwin/ ; sh 'open rdoc/index.html'
50
- when /mswin|mingw/ ; sh 'start rdoc\index.html'
51
- else
52
- sh 'firefox rdoc/index.html'
53
- end
54
- end
55
- end
56
-
57
- if Spec.default_executable
58
- desc "Run #{Spec.default_executable}"
59
- task :run do ruby File.join(Spec.bindir, Spec.default_executable) end
60
- end
61
-
62
- require 'rubygems'
63
-
64
- desc 'Install gem (and sudo if required)'
65
- task :install => :package do
66
- gem_cmd(:install, "pkg/#{Spec.name}-#{Spec.version}.gem")
67
- end
68
-
69
- desc 'Uninstall gem (and sudo if required)'
70
- task :uninstall do
71
- gem_cmd(:uninstall, "#{Spec.name}", "-v=#{Spec.version}")
72
- end
73
-
74
- # Find an scm's store directory, if we do, make a task to commit to it only
75
- # after running all the tests (successfully).
76
- if scm = %w(git svn bzr hg).find { |d| File.directory? ".#{d}" }
77
- desc "Run tests then commit to #{scm}"
78
- task :commit => :test do sh "#{scm} commit" end
79
- end
@@ -1,193 +0,0 @@
1
- # This is used by several rake tasks, that parameterize the
2
- # behavior so we can use the same tests to test both the
3
- # extension and non-extension versions.
4
- def run_tests t, libr = :cascade, test_files="test_*.rb"
5
- require 'test/unit/testsuite'
6
- require 'test/unit/ui/console/testrunner'
7
- require 'tests/testem'
8
-
9
- base_dir = File.expand_path(File.dirname(__FILE__) + '/../') + '/'
10
-
11
- runner = Test::Unit::UI::Console::TestRunner
12
-
13
- $eventmachine_library = libr
14
- EmTestRunner.run(test_files)
15
-
16
- suite = Test::Unit::TestSuite.new($name)
17
-
18
- ObjectSpace.each_object(Class) do |testcase|
19
- suite << testcase.suite if testcase < Test::Unit::TestCase
20
- end
21
-
22
- runner.run(suite)
23
- end
24
-
25
- desc "Run tests for #{Spec.name}."
26
- task :test do |t|
27
- # run_tests t
28
- # Rake +/ friends leave threads, etc, less stable test runs.
29
- ruby "-Ilib -Iext -Iext/fastfilereader -Ijava tests/testem.rb #{'-v' if ENV['VERBOSE']}"
30
- end
31
-
32
- namespace :test do
33
- desc "Run tests for #{Spec.name}."
34
- task :partial do |t|
35
- lib = RUBY_PLATFORM =~ /java/ ? :java : :extension
36
- run_tests t, lib, [
37
- "test_basic.rb",
38
- "test_epoll.rb",
39
- "test_errors.rb",
40
- "test_error_handler.rb",
41
- "test_eventables.rb",
42
- "test_exc.rb",
43
- "test_futures.rb",
44
- "test_hc.rb",
45
- "test_httpclient2.rb",
46
- "test_httpclient.rb",
47
- "test_kb.rb",
48
- "test_ltp2.rb",
49
- "test_ltp.rb",
50
- "test_next_tick.rb",
51
- "test_processes.rb",
52
- "test_pure.rb",
53
- "test_running.rb",
54
- "test_sasl.rb",
55
- "test_send_file.rb",
56
- "test_servers.rb",
57
- "test_smtpclient.rb",
58
- "test_smtpserver.rb",
59
- "test_spawn.rb",
60
- "test_timers.rb",
61
- "test_ud.rb",
62
- ].map { |tf| "tests/#{tf}" }
63
- end
64
-
65
- desc "Run java tests for #$name."
66
- task :testjava do |t|
67
- run_tests t, :java
68
- end
69
-
70
- desc "Run pure-ruby tests for #$name."
71
- task :testpr do |t|
72
- run_tests t, :pure_ruby
73
- end
74
-
75
- desc "Run extension tests for #$name."
76
- task :testext do |t|
77
- run_tests t, :extension
78
- end
79
-
80
- desc "PROVISIONAL: run tests for user-defined events"
81
- task :ud do |t|
82
- run_tests t, :extension, "test_ud.rb"
83
- end
84
-
85
- desc "PROVISIONAL: run tests for line/text protocol handler"
86
- task :ltp do |t|
87
- run_tests t, :extension, "test_ltp*.rb"
88
- end
89
-
90
- desc "PROVISIONAL: run tests for header/content protocol handler"
91
- task :hc do |t|
92
- run_tests t, :extension, "test_hc.rb"
93
- end
94
-
95
- desc "PROVISIONAL: run tests for exceptions"
96
- task :exc do |t|
97
- run_tests t, :extension, "test_exc.rb"
98
- end
99
-
100
- desc "Test protocol handlers"
101
- task :protocols => [ :hc, :ltp ]
102
-
103
-
104
- desc "Test HTTP client"
105
- task :httpclient do |t|
106
- run_tests t, :extension, "test_httpclient.rb"
107
- end
108
-
109
- desc "Test HTTP client2"
110
- task :httpclient2 do |t|
111
- run_tests t, :extension, "test_httpclient2.rb"
112
- end
113
-
114
- desc "Test futures"
115
- task :futures do |t|
116
- run_tests t, :extension, "test_future*.rb"
117
- end
118
-
119
- desc "Test Timers"
120
- task :timers do |t|
121
- run_tests t, :extension, "test_timer*.rb"
122
- end
123
-
124
- desc "Test Next Tick"
125
- task :next_tick do |t|
126
- run_tests t, :extension, "test_next_tick*.rb"
127
- end
128
-
129
- desc "Test Epoll"
130
- task :epoll do |t|
131
- run_tests t, :extension, "test_epoll*.rb"
132
- end
133
-
134
- desc "Test Servers"
135
- task :servers do |t|
136
- run_tests t, :extension, "test_servers*.rb"
137
- end
138
-
139
- desc "Test Basic"
140
- task :basic do |t|
141
- run_tests t, :extension, "test_basic*.rb"
142
- end
143
-
144
- desc "Test Send File"
145
- task :send_file do |t|
146
- run_tests t, :extension, "test_send_file*.rb"
147
- end
148
-
149
- desc "Test Running"
150
- task :running do |t|
151
- run_tests t, :extension, "test_running*.rb"
152
- end
153
-
154
- desc "Test Keyboard Events"
155
- task :keyboard do |t|
156
- run_tests t, :extension, "test_kb*.rb"
157
- end
158
-
159
- desc "Test Spawn"
160
- task :spawn do |t|
161
- run_tests t, :extension, "test_spawn*.rb"
162
- end
163
-
164
- desc "Test SMTP"
165
- task :smtp do |t|
166
- run_tests t, :extension, "test_smtp*.rb"
167
- end
168
-
169
- desc "Test Errors"
170
- task :errors do |t|
171
- run_tests t, :extension, "test_errors*.rb"
172
- end
173
-
174
- desc "Test Pure Ruby"
175
- task :pure do |t|
176
- run_tests t, :extension, "test_pure*.rb"
177
- end
178
-
179
- desc "Test Processes"
180
- task :processes do |t|
181
- run_tests t, :extension, "test_process*.rb"
182
- end
183
-
184
- desc "Test SASL"
185
- task :sasl do |t|
186
- run_tests t, :java, "test_sasl*.rb"
187
- end
188
-
189
- desc "Test Attach"
190
- task :attach do |t|
191
- run_tests t, :extension, "test_attach*.rb"
192
- end
193
- end