cool.io 1.0.0 → 1.9.0
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.
- checksums.yaml +7 -0
- data/.github/workflows/test.yaml +54 -0
- data/.gitignore +30 -0
- data/.rspec +3 -0
- data/{CHANGES → CHANGES.md} +175 -79
- data/{README.markdown → README.md} +43 -49
- data/Rakefile +44 -69
- data/appveyor.yml +18 -0
- data/cool.io.gemspec +18 -131
- data/examples/callbacked_echo_server.rb +24 -0
- data/ext/cool.io/buffer.c +781 -0
- data/ext/cool.io/cool.io.h +13 -0
- data/ext/cool.io/cool.io_ext.c +1 -0
- data/ext/cool.io/ev_wrap.h +4 -2
- data/ext/cool.io/extconf.rb +27 -16
- data/ext/cool.io/iowatcher.c +17 -8
- data/ext/cool.io/loop.c +36 -84
- data/ext/cool.io/stat_watcher.c +103 -25
- data/ext/cool.io/timer_watcher.c +3 -3
- data/ext/cool.io/utils.c +5 -0
- data/ext/cool.io/watcher.h +1 -1
- data/ext/libev/Changes +152 -3
- data/ext/libev/LICENSE +2 -1
- data/ext/libev/README +8 -8
- data/ext/libev/ev.c +1719 -348
- data/ext/libev/ev.h +146 -118
- data/ext/libev/ev_epoll.c +71 -20
- data/ext/libev/ev_kqueue.c +36 -16
- data/ext/libev/ev_poll.c +14 -11
- data/ext/libev/ev_port.c +43 -18
- data/ext/libev/ev_select.c +82 -25
- data/ext/libev/ev_vars.h +28 -21
- data/ext/libev/ev_win32.c +19 -10
- data/ext/libev/ev_wrap.h +166 -152
- data/ext/libev/test_libev_win32.c +1 -1
- data/gems.rb +9 -0
- data/lib/cool.io/async_watcher.rb +1 -1
- data/lib/cool.io/custom_require.rb +9 -0
- data/lib/cool.io/dns_resolver.rb +30 -22
- data/lib/cool.io/dsl.rb +32 -28
- data/lib/cool.io/io.rb +55 -35
- data/lib/cool.io/iowatcher.rb +1 -1
- data/lib/cool.io/listener.rb +35 -17
- data/lib/cool.io/loop.rb +17 -25
- data/lib/cool.io/meta.rb +6 -5
- data/lib/cool.io/server.rb +5 -4
- data/lib/cool.io/socket.rb +41 -30
- data/lib/cool.io/timer_watcher.rb +1 -1
- data/lib/cool.io/version.rb +7 -0
- data/lib/cool.io.rb +11 -10
- data/lib/coolio.rb +1 -1
- data/libev_ruby_gil.diff +175 -0
- data/libev_win_select.diff +130 -0
- data/spec/async_watcher_spec.rb +5 -5
- data/spec/dns_spec.rb +27 -8
- data/spec/iobuffer_spec.rb +147 -0
- data/spec/spec_helper.rb +15 -1
- data/spec/stat_watcher_spec.rb +81 -0
- data/spec/tcp_server_spec.rb +225 -0
- data/spec/tcp_socket_spec.rb +185 -0
- data/spec/timer_watcher_spec.rb +23 -19
- data/spec/udp_socket_spec.rb +58 -0
- data/spec/unix_listener_spec.rb +8 -8
- data/spec/unix_server_spec.rb +10 -8
- metadata +109 -112
- data/VERSION +0 -1
- data/examples/httpclient.rb +0 -38
- data/ext/http11_client/.gitignore +0 -5
- data/ext/http11_client/LICENSE +0 -31
- data/ext/http11_client/ext_help.h +0 -14
- data/ext/http11_client/extconf.rb +0 -6
- data/ext/http11_client/http11_client.c +0 -300
- data/ext/http11_client/http11_parser.c +0 -403
- data/ext/http11_client/http11_parser.h +0 -48
- data/ext/http11_client/http11_parser.rl +0 -173
- data/lib/cool.io/eventmachine.rb +0 -234
- data/lib/cool.io/http_client.rb +0 -419
- data/lib/rev.rb +0 -4
- data/spec/possible_tests/schedules_other_threads.rb +0 -48
- data/spec/possible_tests/test_on_resolve_failed.rb +0 -9
- data/spec/possible_tests/test_resolves.rb +0 -27
- data/spec/possible_tests/test_write_during_resolve.rb +0 -27
- data/spec/possible_tests/works_straight.rb +0 -71
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../rev'
|
|
2
|
-
|
|
3
|
-
ADDR = 'wilkboardonline.com'
|
|
4
|
-
PORT = 80
|
|
5
|
-
|
|
6
|
-
class ClientConnection < Rev::TCPSocket
|
|
7
|
-
def on_connect
|
|
8
|
-
puts "#{remote_addr}:#{remote_port} connected"
|
|
9
|
-
write ("GET / HTTP/1.1\r\nhost:wilkboardonline.com:80\r\nconnection:close\r\n\r\n")
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def on_close
|
|
13
|
-
puts "#{remote_addr}:#{remote_port} disconnected"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def on_read(data)
|
|
17
|
-
print "got #{data}"
|
|
18
|
-
close
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
event_loop = Rev::Loop.default
|
|
24
|
-
client = ClientConnection.connect(ADDR, PORT)
|
|
25
|
-
client.attach(event_loop)
|
|
26
|
-
puts "Echo client started to #{ADDR}:#{PORT}"
|
|
27
|
-
event_loop.run
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../rev'
|
|
2
|
-
|
|
3
|
-
ADDR = 'wilkboardonline.com'
|
|
4
|
-
PORT = 80
|
|
5
|
-
|
|
6
|
-
class ClientConnection < Rev::TCPSocket
|
|
7
|
-
def on_connect
|
|
8
|
-
puts "#{remote_addr}:#{remote_port} connected"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def on_close
|
|
12
|
-
puts "#{remote_addr}:#{remote_port} disconnected"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def on_read(data)
|
|
16
|
-
print "got #{data}"
|
|
17
|
-
close
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
event_loop = Rev::Loop.default
|
|
23
|
-
client = ClientConnection.connect(ADDR, PORT)
|
|
24
|
-
client.write ("GET / HTTP/1.1\r\nhost:wilkboardonline.com:80\r\nconnection:close\r\n\r\n")
|
|
25
|
-
client.attach(event_loop)
|
|
26
|
-
puts "Echo client started to #{ADDR}:#{PORT}"
|
|
27
|
-
event_loop.run
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../lib/rev'
|
|
2
|
-
def dbg
|
|
3
|
-
require 'rubygems'
|
|
4
|
-
require 'ruby-debug'
|
|
5
|
-
debugger
|
|
6
|
-
end
|
|
7
|
-
Thread.abort_on_exception=true
|
|
8
|
-
|
|
9
|
-
require 'socket'
|
|
10
|
-
|
|
11
|
-
describe Rev::TCPSocket do
|
|
12
|
-
HOST = '127.0.0.1'
|
|
13
|
-
PORT = 4321
|
|
14
|
-
before :each do
|
|
15
|
-
@server = Rev::TCPServer.new(HOST, PORT) do |c|
|
|
16
|
-
c.on_connect { puts "#{remote_addr}:#{remote_port} connected" }
|
|
17
|
-
c.on_close { puts "#{remote_addr}:#{remote_port} disconnected" }
|
|
18
|
-
#c.on_read { |data| write data }
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
after :each do
|
|
24
|
-
@server.close
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def sleep_until(seconds = 1, interval = 0.1)
|
|
28
|
-
raise unless block_given?
|
|
29
|
-
start_time=Time.now
|
|
30
|
-
sleep interval until ((Time.now - start_time) > seconds) or yield
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "should stop" do
|
|
34
|
-
loop = Rev::Loop.default
|
|
35
|
-
stopped = false;
|
|
36
|
-
@server.attach(loop)
|
|
37
|
-
Thread.new {
|
|
38
|
-
loop.run_nonblock_over_and_over_again
|
|
39
|
-
stopped = true
|
|
40
|
-
}
|
|
41
|
-
sleep 0
|
|
42
|
-
stopped.should == false
|
|
43
|
-
loop.stop
|
|
44
|
-
|
|
45
|
-
sleep_until { stopped == true }
|
|
46
|
-
stopped.should == true
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "should auto bind on 1.8.6" do
|
|
50
|
-
@server.close
|
|
51
|
-
loop = Rev::Loop.default
|
|
52
|
-
server = Rev::TCPServer.new(HOST, PORT) do |c|
|
|
53
|
-
#c.on_connect { puts "#{remote_addr}:#{remote_port} connected" }
|
|
54
|
-
#c.on_close { puts "#{remote_addr}:#{remote_port} disconnected" }
|
|
55
|
-
print "CREATING\n"
|
|
56
|
-
c.on_read { |conn, data| print "WITHIN MYINE"; conn.write data; conn.close; loop.stop }
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
server.attach(loop)
|
|
60
|
-
|
|
61
|
-
Thread.new { loop.run_nonblock_over_and_over_again }
|
|
62
|
-
puts "Echo server listening on #{HOST}:#{PORT}"
|
|
63
|
-
# now connect and write -- it should close
|
|
64
|
-
connector = TCPSocket.new HOST, PORT
|
|
65
|
-
connector.write "yup"
|
|
66
|
-
connector.read.should == 'yup'
|
|
67
|
-
sleep 0
|
|
68
|
-
loop.running?.should != true
|
|
69
|
-
connector.closed?.should == true # it should close me, too
|
|
70
|
-
end
|
|
71
|
-
end
|