eventmachine 0.10.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/DEFERRABLES +1 -1
  2. data/LIGHTWEIGHT_CONCURRENCY +1 -1
  3. data/PURE_RUBY +1 -1
  4. data/README +1 -1
  5. data/RELEASE_NOTES +1 -1
  6. data/SMTP +1 -1
  7. data/SPAWNED_PROCESSES +1 -1
  8. data/TODO +1 -1
  9. data/ext/binder.cpp +1 -1
  10. data/ext/binder.h +1 -1
  11. data/ext/cmain.cpp +29 -1
  12. data/ext/cplusplus.cpp +1 -1
  13. data/ext/ed.cpp +79 -1
  14. data/ext/ed.h +6 -1
  15. data/ext/em.cpp +343 -27
  16. data/ext/em.h +25 -1
  17. data/ext/emwin.cpp +1 -1
  18. data/ext/emwin.h +1 -1
  19. data/ext/epoll.cpp +1 -1
  20. data/ext/epoll.h +1 -1
  21. data/ext/eventmachine.h +3 -1
  22. data/ext/eventmachine_cpp.h +1 -1
  23. data/ext/extconf.rb +31 -1
  24. data/ext/files.cpp +1 -1
  25. data/ext/files.h +1 -1
  26. data/ext/kb.cpp +4 -1
  27. data/ext/page.cpp +1 -1
  28. data/ext/page.h +1 -1
  29. data/ext/pipe.cpp +4 -1
  30. data/ext/project.h +8 -2
  31. data/ext/rubymain.cpp +73 -2
  32. data/ext/sigs.cpp +1 -1
  33. data/ext/sigs.h +1 -1
  34. data/ext/ssl.cpp +4 -1
  35. data/ext/ssl.h +1 -1
  36. data/lib/em/deferrable.rb +1 -1
  37. data/lib/em/eventable.rb +1 -1
  38. data/lib/em/future.rb +1 -1
  39. data/lib/em/messages.rb +1 -1
  40. data/lib/em/processes.rb +68 -0
  41. data/lib/em/spawnable.rb +1 -1
  42. data/lib/em/streamer.rb +1 -1
  43. data/lib/eventmachine.rb +113 -66
  44. data/lib/eventmachine_version.rb +2 -2
  45. data/lib/evma.rb +1 -1
  46. data/lib/evma/callback.rb +1 -1
  47. data/lib/evma/container.rb +1 -1
  48. data/lib/evma/factory.rb +1 -1
  49. data/lib/evma/protocol.rb +1 -1
  50. data/lib/evma/reactor.rb +1 -1
  51. data/lib/jeventmachine.rb +1 -1
  52. data/lib/pr_eventmachine.rb +35 -8
  53. data/lib/protocols/header_and_content.rb +1 -1
  54. data/lib/protocols/httpcli2.rb +1 -1
  55. data/lib/protocols/httpclient.rb +1 -1
  56. data/lib/protocols/line_and_text.rb +1 -1
  57. data/lib/protocols/linetext2.rb +1 -1
  58. data/lib/protocols/saslauth.rb +59 -1
  59. data/lib/protocols/smtpclient.rb +4 -3
  60. data/lib/protocols/smtpserver.rb +3 -3
  61. data/lib/protocols/stomp.rb +1 -1
  62. data/lib/protocols/tcptest.rb +1 -1
  63. data/tests/test_basic.rb +2 -1
  64. data/tests/test_defer.rb +63 -0
  65. data/tests/test_epoll.rb +10 -5
  66. data/tests/test_errors.rb +13 -3
  67. data/tests/test_eventables.rb +1 -1
  68. data/tests/test_exc.rb +2 -1
  69. data/tests/test_futures.rb +2 -1
  70. data/tests/test_hc.rb +26 -2
  71. data/tests/test_httpclient.rb +2 -1
  72. data/tests/test_httpclient2.rb +2 -1
  73. data/tests/test_kb.rb +2 -1
  74. data/tests/test_ltp.rb +3 -1
  75. data/tests/test_ltp2.rb +2 -1
  76. data/tests/test_next_tick.rb +2 -1
  77. data/tests/test_processes.rb +56 -0
  78. data/tests/test_pure.rb +2 -1
  79. data/tests/test_running.rb +2 -1
  80. data/tests/test_sasl.rb +73 -0
  81. data/tests/test_send_file.rb +3 -1
  82. data/tests/test_servers.rb +4 -1
  83. data/tests/test_smtpclient.rb +2 -1
  84. data/tests/test_smtpserver.rb +3 -2
  85. data/tests/test_spawn.rb +2 -1
  86. data/tests/test_timers.rb +2 -2
  87. data/tests/test_ud.rb +2 -1
  88. data/tests/testem.rb +1 -1
  89. metadata +115 -104
@@ -1,4 +1,4 @@
1
- # $Id: test_futures.rb 534 2007-09-15 23:06:15Z blackhedd $
1
+ # $Id: test_futures.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -26,6 +26,7 @@
26
26
 
27
27
  $:.unshift "../lib"
28
28
  require 'eventmachine'
29
+ require 'test/unit'
29
30
 
30
31
 
31
32
 
data/tests/test_hc.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: test_hc.rb 323 2007-05-22 22:22:43Z blackhedd $
1
+ # $Id: test_hc.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -26,6 +26,14 @@
26
26
 
27
27
  $:.unshift "../lib"
28
28
  require 'eventmachine'
29
+ require 'socket'
30
+ require 'test/unit'
31
+
32
+ # This doesn't completely work under Ruby 1.9.
33
+ # Part of it is thread race conditions. I added some sleeps to make these
34
+ # tests work. Native threads do strange things when you do I/O on them.
35
+ #
36
+
29
37
 
30
38
  class TestHeaderAndContentProtocol < Test::Unit::TestCase
31
39
 
@@ -66,6 +74,10 @@ class TestHeaderAndContentProtocol < Test::Unit::TestCase
66
74
  "aaa\n", "bbb\r\n", "ccc\n", "\n"
67
75
  ].join
68
76
  t.close
77
+ if RUBY_VERSION =~ /\A1\.9\./
78
+ sleep 0.1
79
+ STDERR.puts "Introducing extraneous sleep for Ruby 1.9"
80
+ end
69
81
  }, proc {
70
82
  EventMachine.stop
71
83
  }
@@ -91,8 +103,12 @@ class TestHeaderAndContentProtocol < Test::Unit::TestCase
91
103
  t.write "\n"
92
104
  t.write content
93
105
  t.close
106
+ if RUBY_VERSION =~ /\A1\.9\./
107
+ sleep 0.1
108
+ STDERR.puts "Introducing extraneous sleep for Ruby 1.9"
109
+ end
94
110
  }, proc {
95
- EventMachine.stop
111
+ EM.stop
96
112
  }
97
113
  }
98
114
  assert_equal( ["aaa"], the_connection.first_header )
@@ -118,6 +134,10 @@ class TestHeaderAndContentProtocol < Test::Unit::TestCase
118
134
  t.write content
119
135
  }
120
136
  t.close
137
+ if RUBY_VERSION =~ /\A1\.9\./
138
+ sleep 0.1
139
+ STDERR.puts "Introducing extraneous sleep for Ruby 1.9"
140
+ end
121
141
  }, proc {
122
142
  EventMachine.stop
123
143
  }
@@ -173,6 +193,10 @@ class TestHeaderAndContentProtocol < Test::Unit::TestCase
173
193
  t.write "\n"
174
194
  t.write content
175
195
  t.close
196
+ if RUBY_VERSION =~ /\A1\.9\./
197
+ sleep 0.1
198
+ STDERR.puts "Introducing extraneous sleep for Ruby 1.9"
199
+ end
176
200
  }, proc {
177
201
  EventMachine.stop
178
202
  }
@@ -1,4 +1,4 @@
1
- # $Id: test_httpclient.rb 518 2007-08-30 10:17:02Z blackhedd $
1
+ # $Id: test_httpclient.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -26,6 +26,7 @@
26
26
 
27
27
  $:.unshift "../lib"
28
28
  require 'eventmachine'
29
+ require 'test/unit'
29
30
 
30
31
  class TestHttpClient < Test::Unit::TestCase
31
32
 
@@ -1,4 +1,4 @@
1
- # $Id: test_httpclient.rb 518 2007-08-30 10:17:02Z blackhedd $
1
+ # $Id: test_httpclient2.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -26,6 +26,7 @@
26
26
 
27
27
  $:.unshift "../lib"
28
28
  require 'eventmachine'
29
+ require 'test/unit'
29
30
 
30
31
  class TestHttpClient2 < Test::Unit::TestCase
31
32
  Localhost = "127.0.0.1"
data/tests/test_kb.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: test_kb.rb 502 2007-08-24 09:29:53Z blackhedd $
1
+ # $Id: test_kb.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -26,6 +26,7 @@
26
26
 
27
27
  $:.unshift "../lib"
28
28
  require 'eventmachine'
29
+ require 'test/unit'
29
30
 
30
31
  class TestKeyboardEvents < Test::Unit::TestCase
31
32
 
data/tests/test_ltp.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: test_ltp.rb 448 2007-07-21 00:15:05Z blackhedd $
1
+ # $Id: test_ltp.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -27,6 +27,8 @@
27
27
 
28
28
  $:.unshift "../lib"
29
29
  require 'eventmachine'
30
+ require 'socket'
31
+ require 'test/unit'
30
32
 
31
33
  class TestLineAndTextProtocol < Test::Unit::TestCase
32
34
 
data/tests/test_ltp2.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: test_ltp2.rb 486 2007-07-29 17:15:12Z blackhedd $
1
+ # $Id: test_ltp2.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -27,6 +27,7 @@
27
27
 
28
28
  $:.unshift "../lib"
29
29
  require 'eventmachine'
30
+ require 'test/unit'
30
31
 
31
32
  # TODO!!! Need tests for overlength headers and text bodies.
32
33
 
@@ -1,4 +1,4 @@
1
- # $Id: test_next_tick.rb 381 2007-06-15 19:48:11Z blackhedd $
1
+ # $Id: test_next_tick.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -27,6 +27,7 @@
27
27
 
28
28
  $:.unshift "../lib"
29
29
  require 'eventmachine'
30
+ require 'test/unit'
30
31
 
31
32
 
32
33
 
@@ -0,0 +1,56 @@
1
+ # $Id: test_processes.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 TestProcesses < Test::Unit::TestCase
32
+
33
+ # EM::DeferrableChildProcess is a sugaring of a common use-case
34
+ # involving EM::popen.
35
+ # Call the #open method on EM::DeferrableChildProcess, passing
36
+ # a command-string. #open immediately returns an EM::Deferrable
37
+ # object. It also schedules the forking of a child process, which
38
+ # will execute the command passed to #open.
39
+ # When the forked child terminates, the Deferrable will be signalled
40
+ # and execute its callbacks, passing the data that the child process
41
+ # wrote to stdout.
42
+ #
43
+ def test_deferrable_child_process
44
+ ls = ""
45
+ EM.run {
46
+ d = EM::DeferrableChildProcess.open( "ls -ltr" )
47
+ d.callback {|data_from_child|
48
+ ls = data_from_child
49
+ EM.stop
50
+ }
51
+ }
52
+ assert( ls.length > 0)
53
+ end
54
+
55
+ end
56
+
data/tests/test_pure.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: test_pure.rb 604 2007-12-06 12:31:39Z blackhedd $
1
+ # $Id: test_pure.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -26,6 +26,7 @@
26
26
 
27
27
  $:.unshift "../lib"
28
28
  require 'eventmachine'
29
+ require 'test/unit'
29
30
 
30
31
  class TestPure < Test::Unit::TestCase
31
32
 
@@ -1,4 +1,4 @@
1
- # $Id: test_running.rb 493 2007-08-13 20:10:46Z blackhedd $
1
+ # $Id: test_running.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -26,6 +26,7 @@
26
26
 
27
27
  $:.unshift "../lib"
28
28
  require 'eventmachine'
29
+ require 'test/unit'
29
30
 
30
31
  class TestRunning < Test::Unit::TestCase
31
32
  def setup
@@ -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
+
@@ -1,4 +1,4 @@
1
- # $Id: test_send_file.rb 481 2007-07-28 18:41:17Z blackhedd $
1
+ # $Id: test_send_file.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -26,6 +26,8 @@
26
26
 
27
27
  $:.unshift "../lib"
28
28
  require 'eventmachine'
29
+ require 'socket'
30
+ require 'test/unit'
29
31
 
30
32
  class TestSendFile < Test::Unit::TestCase
31
33
 
@@ -1,4 +1,4 @@
1
- # $Id: test_servers.rb 426 2007-07-17 16:54:08Z blackhedd $
1
+ # $Id: test_servers.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -26,6 +26,9 @@
26
26
 
27
27
  $:.unshift "../lib"
28
28
  require 'eventmachine'
29
+ require 'socket'
30
+ require 'test/unit'
31
+
29
32
 
30
33
  class TestServers < Test::Unit::TestCase
31
34
 
@@ -1,4 +1,4 @@
1
- # $Id: test_smtpclient.rb 535 2007-09-16 19:35:05Z blackhedd $
1
+ # $Id: test_smtpclient.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -26,6 +26,7 @@
26
26
 
27
27
  $:.unshift "../lib"
28
28
  require 'eventmachine'
29
+ require 'test/unit'
29
30
 
30
31
  class TestSmtpClient < Test::Unit::TestCase
31
32
 
@@ -1,4 +1,4 @@
1
- # $Id: test_smtpserver.rb 523 2007-09-05 23:29:02Z blackhedd $
1
+ # $Id: test_smtpserver.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -26,6 +26,7 @@
26
26
 
27
27
  $:.unshift "../lib"
28
28
  require 'eventmachine'
29
+ require 'test/unit'
29
30
 
30
31
  class TestSmtpServer < Test::Unit::TestCase
31
32
 
@@ -47,7 +48,7 @@ class TestSmtpServer < Test::Unit::TestCase
47
48
  end
48
49
  def receive_sender sender
49
50
  @my_sender = sender
50
- p sender
51
+ #p sender
51
52
  true
52
53
  end
53
54
  def receive_recipient rcpt
data/tests/test_spawn.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: test_spawn.rb 532 2007-09-13 21:44:23Z blackhedd $
1
+ # $Id: test_spawn.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -28,6 +28,7 @@
28
28
 
29
29
  $:.unshift "../lib"
30
30
  require 'eventmachine'
31
+ require 'test/unit'
31
32
 
32
33
 
33
34
 
data/tests/test_timers.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: test_timers.rb 597 2007-12-05 12:48:36Z blackhedd $
1
+ # $Id: test_timers.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -27,7 +27,7 @@
27
27
 
28
28
  $:.unshift "../lib"
29
29
  require 'eventmachine'
30
-
30
+ require 'test/unit'
31
31
 
32
32
 
33
33
  class TestTimers < Test::Unit::TestCase
data/tests/test_ud.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: test_ud.rb 323 2007-05-22 22:22:43Z blackhedd $
1
+ # $Id: test_ud.rb 668 2008-01-04 23:00:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -26,6 +26,7 @@
26
26
 
27
27
  $:.unshift "../lib"
28
28
  require 'eventmachine'
29
+ require 'test/unit'
29
30
 
30
31
  class TestUserDefinedEvents < Test::Unit::TestCase
31
32