eventmachine 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- # $Id: eventmachine_version.rb 324 2007-05-22 22:43:35Z blackhedd $
1
+ # $Id: eventmachine_version.rb 389 2007-06-25 02:07:04Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -25,7 +25,7 @@
25
25
 
26
26
  module EventMachine
27
27
 
28
- VERSION = "0.7.2"
28
+ VERSION = "0.8.0"
29
29
 
30
30
  end
31
31
 
@@ -75,6 +75,11 @@ class BufferedTokenizer
75
75
  # and add it to our list of discovered entities.
76
76
  entities.unshift @input.join
77
77
 
78
+ =begin
79
+ # Note added by FC, 10Jul07. This paragraph contains a regression. It breaks
80
+ # empty tokens. Think of the empty line that delimits an HTTP header. It will have
81
+ # two "\n" delimiters in a row, and this code mishandles the resulting empty token.
82
+ # It someone figures out how to fix the problem, we can re-enable this code branch.
78
83
  # Multi-character token support.
79
84
  # Split any tokens that were incomplete on the last iteration buf complete now.
80
85
  entities.map! do |e|
@@ -88,6 +93,7 @@ class BufferedTokenizer
88
93
  else
89
94
  entities.flatten!
90
95
  end
96
+ =end
91
97
 
92
98
  # Now that we've hit a token, joined the input buffer and added it to the entities
93
99
  # list, we can go ahead and clear the input buffer. All of the segments that were
@@ -1,4 +1,4 @@
1
- # $Id: httpclient.rb 322 2007-05-22 22:18:35Z blackhedd $
1
+ # $Id: httpclient.rb 398 2007-07-11 02:46:22Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -120,8 +120,9 @@ class HttpClient < Connection
120
120
  raise "oversized content in HTTP POST" if postcontent.length > MaxPostContentLength
121
121
 
122
122
  # ESSENTIAL for the request's line-endings to be CRLF, not LF. Some servers misbehave otherwise.
123
+ # TODO: We ASSUME the caller wants to send a 1.1 request. May not be a good assumption.
123
124
  req = [
124
- "#{verb} #{request}#{qs} HTTP/1.0",
125
+ "#{verb} #{request}#{qs} HTTP/1.1",
125
126
  "Host: #{host}:#{port}",
126
127
  "User-agent: Ruby EventMachine",
127
128
  ]
@@ -1,4 +1,4 @@
1
- # $Id: line_and_text.rb 322 2007-05-22 22:18:35Z blackhedd $
1
+ # $Id: line_and_text.rb 380 2007-06-13 19:10:15Z tarcieri $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -39,7 +39,9 @@ module EventMachine
39
39
  def receive_data data
40
40
  if @lbp_mode == :lines
41
41
  begin
42
- @lpb_buffer.extract(data).each { |line| receive_line(line) if respond_to?(:receive_line) }
42
+ @lpb_buffer.extract(data).each do |line|
43
+ receive_line(line.chomp) if respond_to?(:receive_line)
44
+ end
43
45
  rescue Exception
44
46
  receive_error('overlength line') if respond_to?(:receive_error)
45
47
  close_connection
@@ -0,0 +1,154 @@
1
+ # $Id: test_epoll.rb 373 2007-06-08 16:09:01Z 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
+ # TODO, and I know this doesn't belong here, but if a datagram calls
27
+ # send_data outside of a receive_data, there is no return address, and
28
+ # the result is a very confusing error message.
29
+ #
30
+
31
+ $:.unshift "../lib"
32
+ require 'eventmachine'
33
+
34
+
35
+
36
+ class TestEpoll < Test::Unit::TestCase
37
+
38
+ def setup
39
+ end
40
+
41
+ def teardown
42
+ end
43
+
44
+
45
+ module TestEchoServer
46
+ def receive_data data
47
+ send_data data
48
+ close_connection_after_writing
49
+ end
50
+ end
51
+
52
+ module TestEchoClient
53
+ def connection_completed
54
+ send_data "ABCDE"
55
+ $max += 1
56
+ end
57
+ def receive_data data
58
+ raise "bad response" unless data == "ABCDE"
59
+ end
60
+ def unbind
61
+ $n -= 1
62
+ EM.stop if $n == 0
63
+ end
64
+ end
65
+
66
+
67
+ # We can set the rlimit/nofile of a process but we can only set it
68
+ # higher if we're running as root.
69
+ # On most systems, the default value is 1024.
70
+ def test_rlimit
71
+ a = EM.set_descriptor_table_size
72
+ assert( a <= 1024 )
73
+ a = EM.set_descriptor_table_size( 1024 )
74
+ assert( a == 1024 )
75
+ end
76
+
77
+ # Run a high-volume version of this test by kicking the number of connections
78
+ # up past 512. (Each connection uses two sockets, a client and a server.)
79
+ # (Will require running the test as root)
80
+ # This test exercises TCP clients and servers.
81
+ #
82
+ def test_descriptors
83
+ EM.epoll
84
+ s = EM.set_descriptor_table_size 60000
85
+ EM.run {
86
+ EM.start_server "127.0.0.1", 9800, TestEchoServer
87
+ $n = 0
88
+ $max = 0
89
+ 100.times {
90
+ EM.connect("127.0.0.1", 9800, TestEchoClient) {$n += 1}
91
+ }
92
+ }
93
+ assert_equal(0, $n)
94
+ assert_equal(100, $max)
95
+ end
96
+
97
+ def test_defer
98
+ $n = 0
99
+ EM.epoll
100
+ EM.run {
101
+ sleep_proc = proc {sleep 1}
102
+ return_proc = proc {$n += 1; EM.stop}
103
+ EM.defer sleep_proc, return_proc
104
+ }
105
+ assert_equal( 1, $n )
106
+ end
107
+
108
+
109
+ module TestDatagramServer
110
+ def receive_data dgm
111
+ $in = dgm
112
+ send_data "abcdefghij"
113
+ end
114
+ end
115
+ module TestDatagramClient
116
+ def post_init
117
+ send_datagram "1234567890", "127.0.0.1", 9500
118
+ end
119
+ def receive_data dgm
120
+ $out = dgm
121
+ EM.stop
122
+ end
123
+ end
124
+
125
+ def test_datagrams
126
+ $in = $out = ""
127
+ EM.epoll
128
+ EM.run {
129
+ EM.open_datagram_socket "127.0.0.1", 9500, TestDatagramServer
130
+ EM.open_datagram_socket "127.0.0.1", 0, TestDatagramClient
131
+ }
132
+ assert_equal( "1234567890", $in )
133
+ assert_equal( "abcdefghij", $out )
134
+ end
135
+
136
+
137
+
138
+
139
+ def test_unix_domain
140
+ EM.epoll
141
+ s = EM.set_descriptor_table_size 60000
142
+ EM.run {
143
+ EM.start_unix_domain_server "./xxx.chain", TestEchoServer
144
+ $n = 0
145
+ $max = 0
146
+ 100.times {
147
+ EM.connect_unix_domain("./xxx.chain", TestEchoClient) {$n += 1}
148
+ }
149
+ }
150
+ assert_equal(0, $n)
151
+ assert_equal(100, $max)
152
+ end
153
+
154
+ end
@@ -1,4 +1,4 @@
1
- # $Id: test_eventables.rb 323 2007-05-22 22:22:43Z blackhedd $
1
+ # $Id: test_eventables.rb 399 2007-07-11 02:50:20Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -43,7 +43,10 @@ class TestEventables < Test::Unit::TestCase
43
43
  def teardown
44
44
  end
45
45
 
46
- def test_a
46
+ def test_a; end # shut up rake until we define a test.
47
+
48
+ # TODO, this idea is still half-baked.
49
+ def xxx_test_a
47
50
  n = 0
48
51
  tester = EvTest.new
49
52
  tester.listen_event( :fire1 ) {|arg|
@@ -56,7 +59,7 @@ class TestEventables < Test::Unit::TestCase
56
59
  EventMachine::add_timer(1) {EventMachine.stop}
57
60
  }
58
61
 
59
- assert n == 1
62
+ assert_equal( 1, n )
60
63
  end
61
64
 
62
65
  end
@@ -1,4 +1,4 @@
1
- # $Id: test_httpclient.rb 323 2007-05-22 22:22:43Z blackhedd $
1
+ # $Id: test_httpclient.rb 398 2007-07-11 02:46:22Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -152,6 +152,8 @@ class TestHttpClient < Test::Unit::TestCase
152
152
  end
153
153
  end
154
154
 
155
+ # TODO, this is WRONG. The handler is asserting an HTTP 1.1 request, but the client
156
+ # is sending a 1.0 request. Gotta fix the client
155
157
  def test_post
156
158
  response = nil
157
159
  EventMachine.run {
data/tests/test_ltp.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: test_ltp.rb 323 2007-05-22 22:22:43Z blackhedd $
1
+ # $Id: test_ltp.rb 396 2007-07-11 01:49:34Z blackhedd $
2
2
  #
3
3
  # Author:: Francis Cianfrocca (gmail: blackhedd)
4
4
  # Homepage:: http://rubyeventmachine.com
@@ -99,7 +99,7 @@ class TestLineAndTextProtocol < Test::Unit::TestCase
99
99
  end
100
100
  def receive_line line
101
101
  if line =~ /content-length:\s*(\d+)/i
102
- @content_lenth = $1.to_i
102
+ @content_length = $1.to_i
103
103
  elsif line.length == 0
104
104
  set_binary_mode @content_length
105
105
  end
@@ -119,7 +119,7 @@ class TestLineAndTextProtocol < Test::Unit::TestCase
119
119
  EventMachine.start_server( TestHost, TestPort, LineAndTextTest ) do |conn|
120
120
  conn.instance_eval "@lines = lines_received; @text = text_received"
121
121
  end
122
- EventMachine.add_timer(4) {raise "test timed out"}
122
+ EventMachine.add_timer(2) {raise "test timed out"}
123
123
  EventMachine.defer proc {
124
124
  t = TCPSocket.new TestHost, TestPort
125
125
  t.puts "Content-length: 400"
@@ -177,7 +177,6 @@ class TestLineAndTextProtocol < Test::Unit::TestCase
177
177
  end
178
178
 
179
179
  #--------------------------------------------------------------------
180
-
181
180
  end
182
181
 
183
182
 
@@ -0,0 +1,57 @@
1
+ # $Id: test_next_tick.rb 381 2007-06-15 19:48:11Z 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
+
28
+ $:.unshift "../lib"
29
+ require 'eventmachine'
30
+
31
+
32
+
33
+ class TestNextTick < Test::Unit::TestCase
34
+
35
+ def setup
36
+ end
37
+
38
+ def teardown
39
+ end
40
+
41
+ def test_tick_arg
42
+ pr = proc {EM.stop}
43
+ EM.epoll
44
+ EM.run {
45
+ EM.next_tick pr
46
+ }
47
+ assert true
48
+ end
49
+
50
+ def test_tick_block
51
+ EM.epoll
52
+ EM.run {
53
+ EM.next_tick {EM.stop}
54
+ }
55
+ assert true
56
+ end
57
+ end
metadata CHANGED
@@ -3,9 +3,9 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: eventmachine
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.7.2
7
- date: 2007-05-22 00:00:00 -04:00
8
- summary: Ruby/EventMachine socket engine library
6
+ version: 0.8.0
7
+ date: 2007-07-11 00:00:00 -04:00
8
+ summary: Ruby/EventMachine library
9
9
  require_paths:
10
10
  - lib
11
11
  email: garbagecat10@gmail.com
@@ -39,6 +39,8 @@ files:
39
39
  - tests/test_futures.rb
40
40
  - tests/test_exc.rb
41
41
  - tests/test_timers.rb
42
+ - tests/test_epoll.rb
43
+ - tests/test_next_tick.rb
42
44
  - lib/em
43
45
  - lib/protocols
44
46
  - lib/evma
@@ -49,6 +51,7 @@ files:
49
51
  - lib/em/eventable.rb
50
52
  - lib/em/deferrable.rb
51
53
  - lib/em/future.rb
54
+ - lib/em/messages.rb
52
55
  - lib/protocols/httpclient.rb
53
56
  - lib/protocols/tcptest.rb
54
57
  - lib/protocols/line_and_text.rb
@@ -80,9 +83,13 @@ files:
80
83
  - ext/cmain.cpp
81
84
  - ext/ed.cpp
82
85
  - ext/ed.h
86
+ - ext/pipe.cpp
87
+ - ext/epoll.cpp
88
+ - ext/epoll.h
83
89
  - README
84
90
  - RELEASE_NOTES
85
91
  - COPYING
92
+ - EPOLL
86
93
  - GNU
87
94
  - LEGAL
88
95
  - TODO
@@ -98,6 +105,7 @@ extra_rdoc_files:
98
105
  - README
99
106
  - RELEASE_NOTES
100
107
  - COPYING
108
+ - EPOLL
101
109
  - GNU
102
110
  - LEGAL
103
111
  - TODO