cool.io 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.gitignore +26 -0
  2. data/.rspec +3 -0
  3. data/.travis.yml +4 -0
  4. data/{CHANGES → CHANGES.md} +43 -79
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +32 -0
  7. data/{README.markdown → README.md} +0 -4
  8. data/Rakefile +31 -67
  9. data/cool.io.gemspec +25 -133
  10. data/ext/cool.io/extconf.rb +3 -0
  11. data/ext/cool.io/stat_watcher.c +99 -23
  12. data/ext/libev/Changes +24 -0
  13. data/ext/libev/ev.c +78 -32
  14. data/ext/libev/ev.h +11 -8
  15. data/ext/libev/ev_epoll.c +39 -7
  16. data/ext/libev/ev_kqueue.c +5 -5
  17. data/ext/libev/ev_poll.c +5 -5
  18. data/ext/libev/ev_port.c +26 -11
  19. data/ext/libev/ev_select.c +11 -8
  20. data/ext/libev/ev_vars.h +10 -4
  21. data/ext/libev/ev_win32.c +6 -6
  22. data/ext/libev/ev_wrap.h +10 -0
  23. data/lib/cool.io.rb +3 -3
  24. data/lib/cool.io/async_watcher.rb +1 -1
  25. data/lib/cool.io/dns_resolver.rb +14 -12
  26. data/lib/cool.io/dsl.rb +26 -26
  27. data/lib/cool.io/eventmachine.rb +18 -18
  28. data/lib/cool.io/http_client.rb +29 -22
  29. data/lib/cool.io/io.rb +18 -18
  30. data/lib/cool.io/iowatcher.rb +1 -1
  31. data/lib/cool.io/listener.rb +2 -2
  32. data/lib/cool.io/loop.rb +12 -12
  33. data/lib/cool.io/meta.rb +4 -4
  34. data/lib/cool.io/server.rb +3 -3
  35. data/lib/cool.io/socket.rb +36 -28
  36. data/lib/cool.io/timer_watcher.rb +1 -1
  37. data/lib/cool.io/version.rb +5 -0
  38. data/lib/coolio.rb +1 -1
  39. data/spec/stat_watcher_spec.rb +77 -0
  40. metadata +47 -56
  41. data/VERSION +0 -1
  42. data/lib/rev.rb +0 -4
  43. data/spec/possible_tests/schedules_other_threads.rb +0 -48
  44. data/spec/possible_tests/test_on_resolve_failed.rb +0 -9
  45. data/spec/possible_tests/test_resolves.rb +0 -27
  46. data/spec/possible_tests/test_write_during_resolve.rb +0 -27
  47. data/spec/possible_tests/works_straight.rb +0 -71
@@ -0,0 +1,26 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ tmp
21
+
22
+ ## RUBINIUS
23
+ *.rbc
24
+
25
+ ## PROJECT::SPECIFIC
26
+ conftest.dSYM
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --backtrace
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - rbx-2.0
@@ -1,205 +1,169 @@
1
- 1.0.0:
1
+ 1.1.0
2
+ -----
3
+
4
+ * Switch from Jeweler to Bundler for the gem boilerplate
5
+ * Fix firing of Coolio::HttpClient#on_request_complete (#15)
6
+ * Fix failure to resolve Init_cool symbol on win32 mingw (#14)
7
+ * Fix closing /etc/hosts in the DNS resolver (#12)
8
+ * Refactor StatWatcher to pass pervious and current path state ala Node.js
9
+ * spec:valgrind Rake task to run specs under valgrind
10
+ * Use rake-compiler to build cool.io
11
+ * Upgrade to libev 4.04
12
+
13
+ 1.0.0
14
+ -----
2
15
 
3
16
  * Fancy new DSL
4
17
 
5
- 0.9.0:
18
+ 0.9.0
19
+ -----
6
20
 
7
21
  * Rename the project to cool.io
8
-
9
22
  * Bump the version all the way to 0.9! Hell yeah! 1.0 soon!
10
-
11
23
  * Rename the main module from Rev to Coolio, with deprecation warnings for Rev
12
-
13
24
  * Use Jeweler to manage the gem
14
-
15
25
  * Update to RSpec 2.0
16
-
17
26
  * Update to libev 4.01
18
-
19
27
  * Initial Rubinius support
20
28
 
21
- 0.3.2:
29
+ 0.3.2
30
+ -----
22
31
 
23
32
  * Perform a blocking system call if we're the only thread running (1.8 only)
24
-
25
33
  * Run in non-blocking mode if we're the only thread in the process (1.8 only)
26
-
27
34
  * Make Rev::Loop#run_nonblock signal-safe
28
-
29
35
  * Fix spurious firing of Rev::AsyncWatchers
30
36
 
31
- 0.3.1:
37
+ 0.3.1
38
+ -----
32
39
 
33
40
  * Configurable intervals for Rev::StatWatcher
34
-
35
41
  * Fix broken version number :(
36
-
37
42
  * Removed warning about spuriously readable sockets from Rev::Listener
38
-
39
43
  * Rev::Listener ignores ECONNABORTED from accept_nonblock
40
-
41
44
  * Document rationale for EAGAIN/ECONNABORTED handling in Rev::Listener
42
45
 
43
- 0.3.0:
46
+ 0.3.0
47
+ -----
44
48
 
45
49
  * Add Rev::StatWatcher to monitor filesystem changes
46
-
47
50
  * Add Rev::Listener#fileno for accessing the underlying file descriptor
48
-
49
51
  * Support for creating Rev::Listeners from existing TCPServers/UNIXServers
50
-
51
52
  * Upgrade to libev 3.8
52
-
53
53
  * Simplified code loading
54
-
55
54
  * Pull in iobuffer gem and change outstanding uses of Rev::Buffer to IO::Buffer
56
-
57
55
  * Fix memory leaks resulting from strange semantics of Ruby's xrealloc
58
-
59
56
  * Rev::UNIXServer: use path instead of the first argument
60
-
61
57
  * Rev::Server-based classes can build off ::*Server objects
62
58
 
63
- 0.2.4:
59
+ 0.2.4
60
+ -----
64
61
 
65
62
  * Ugh, botched my first release from the git repo. Oh well. Try, try again.
66
63
 
67
- 0.2.3:
64
+ 0.2.3
65
+ -----
68
66
 
69
67
  * Initial Windows support
70
-
71
68
  * Initial Ruby 1.8.7 and 1.9.1 support
72
-
73
69
  * Upgrade to libev 3.52
74
-
75
70
  * Add checks for sys/resource.h and don't allow getting/setting maxfds if it
76
71
  isn't present
77
72
 
78
- 0.2.2:
73
+ 0.2.2
74
+ -----
79
75
 
80
76
  * Correct a pointer arithmetic error in the buffering code that could result
81
77
  in data corruption.
82
-
83
78
  * Upgrade to libev 3.41
84
-
85
79
  * Relax HTTP/1.1 reponse parser to allow the "reason" portion of the response
86
80
  header to be omitted
87
81
 
88
- 0.2.1:
82
+ 0.2.1
83
+ -----
89
84
 
90
85
  * Upgrade to libev 3.31
91
-
92
86
  * Rev::Loop#run_once and Rev::Loop#run_nonblock now return the number of events
93
87
  received when they were running
94
-
95
88
  * Remove inheritence relationship between Rev::IO and Rev::IOWatcher
96
-
97
89
  * Loosen HTTP/1.1 response parser to accept a common malformation in HTTP/1.1
98
90
  chunk headers
99
-
100
91
  * Add underscore prefix to instance variables to avoid conflicts in subclasses
101
-
102
92
  * Remove Rev::SSLServer until it can be made more useful
103
93
 
104
- 0.2.0:
94
+ 0.2.0
95
+ -----
105
96
 
106
97
  * Initial Ruby 1.8.6 support
107
-
108
98
  * Omit Rev::LIBEV_VERSION constant
109
-
110
99
  * Catch Errno::ECONNRESET when writing to sockets
111
-
112
100
  * SSL support via Rev::SSL, with a small C extension subclassing Ruby's
113
101
  OpenSSL::SSL::SSLSocket allowing for non-blocking SSL handshakes
114
-
115
102
  * Initial Rev::Utils implementation with #ncpus and methods to query and
116
103
  change the maximum number of file descriptors for the current process.
117
-
118
104
  * Initial Rev::AsyncWatcher implementation for cross-thread signaling
119
-
120
105
  * Handle unspecified Content-Length when encoding is identity in HttpClient
121
-
122
106
  * Fix bug in HttpClient processing zero Content-Length
123
-
124
107
  * Get rid of method_missing stuff in Rev::HttpClient
125
-
126
108
  * Have Rev::HttpClient close the connection on error
127
-
128
109
  * Allow Rev::TCPSocket#on_connect to be private when accepting connections
129
110
  from a Rev::TCPServer
130
111
 
131
- 0.1.4:
112
+ 0.1.4
113
+ -----
132
114
 
133
115
  * Calibrate Rev::TimerWatchers against ev_time() and ev_now() when the watcher
134
116
  is attached to the loop to ensure that the timeout interval is correct.
135
-
136
117
  * Add check to ensure that a Rev::Loop cannot be run from within a callback
137
-
138
118
  * Store Rev::Loop.default in a Thread-specific instance variable
139
-
140
119
  * Upgrade libev to 0.3.0
141
-
142
120
  * Rename BufferedIO to IO
143
-
144
121
  * Fixed bug in BufferedIO#write_output_buffer causing it to spin endlessly on
145
122
  an empty buffer.
146
-
147
123
  * Added has_active_watchers? to Rev::Loop to check for active watchers
148
124
 
149
- 0.1.3:
125
+ 0.1.3
126
+ -----
150
127
 
151
128
  * Fixed bug in Rev::Buffer read_from and write_to: now rb_sys_fail on failed
152
129
  reads/writes.
153
-
154
130
  * Change Rev::Buffer memory pools to purge on a periodic interval, rather than
155
131
  whenever the GC marks the object.
156
-
157
132
  * Fix bug in tracking the active watcher count. Factor shared watcher behavior
158
133
  from rev_watcher.h to rev_watcher.c.
159
134
 
160
- 0.1.2:
135
+ 0.1.2
136
+ -----
161
137
 
162
138
  * Commit initial specs
163
-
164
139
  * Improve RDoc for the library
165
-
166
140
  * Eliminate "zero copy" writes as they bypass the event loop
167
-
168
141
  * Added Rev::Buffer C extension to provide high speed buffered writes
169
-
170
142
  * Implement Rev::TCPSocket#peeraddr to improve compatibility with Ruby sockets
171
-
172
143
  * Added Rev::Listener.close for clean shutdown of a listener
173
-
174
144
  * Rev::Loop.default used to call ev_loop_default() (in C). However, this
175
145
  registers signal handlers which conflict with Ruby's own. Now the behavior
176
146
  has been changed to return a thread-local singleton of Rev::Loop.
177
-
178
147
  * Creating a new Rev::TCPListener will disable reverse lookups in BasicSocket
179
-
180
148
  * Made backlog for Rev::TCPListener user-definable
181
-
182
149
  * Rev::TCPSocket now implements an on_resolve_failed callback for failed DNS
183
150
  resolution. By default it's aliased to on_connect_failed.
184
-
185
151
  * Changed event_callbacks to use instance_exec rather than passing the
186
152
  watcher object as an argument. Documented use of defining an event
187
153
  callback as a block
188
-
189
154
  * Subsecond precision for Rev::TimerWatchers
190
155
 
191
- 0.1.1:
156
+ 0.1.1
157
+ -----
192
158
 
193
159
  * Added Rev::HttpClient, an asynchronous HTTP/1.1 client written on top of
194
160
  the Rev::TCPSocket class
195
-
196
161
  * Imported HTTP response parser from the RFuzz project
197
-
198
162
  * Added exception handling for Errno::ECONNRESET and Errno::EAGAIN
199
-
200
163
  * Fixed bugs in buffered writer which resulted in exceptions if all data
201
164
  couldn't be written with a nonblocking write.
202
165
 
203
- 0.1.0:
166
+ 0.1.0
167
+ -----
204
168
 
205
- * Initial public release
169
+ * Initial public release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cool.io.gemspec
4
+ gemspec
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cool.io (1.1.0)
5
+ iobuffer (>= 1.0.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.2)
11
+ iobuffer (1.0.0)
12
+ rake (0.9.2)
13
+ rake-compiler (0.7.9)
14
+ rake
15
+ rdoc (3.6.1)
16
+ rspec (2.6.0)
17
+ rspec-core (~> 2.6.0)
18
+ rspec-expectations (~> 2.6.0)
19
+ rspec-mocks (~> 2.6.0)
20
+ rspec-core (2.6.4)
21
+ rspec-expectations (2.6.0)
22
+ diff-lcs (~> 1.1.2)
23
+ rspec-mocks (2.6.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ cool.io!
30
+ rake-compiler (~> 0.7.9)
31
+ rdoc (>= 3.6.0)
32
+ rspec (>= 2.6.0)
@@ -19,10 +19,6 @@ You can include Cool.io in your programs with:
19
19
 
20
20
  Questions? Sign up for the mailing list by emailing: [cool.io@librelist.com](mailto:cool.io@librelist.com)
21
21
 
22
- The latest development code is available via github at:
23
-
24
- [git://github.com/tarcieri/cool.io.git](git://github.com/tarcieri/cool.io.git)
25
-
26
22
  Anatomy
27
23
  -------
28
24
 
data/Rakefile CHANGED
@@ -1,43 +1,16 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ require 'bundler/gem_tasks'
3
2
  require 'rake/clean'
4
3
 
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "cool.io"
9
- gem.summary = "The cool event framework for Ruby"
10
- gem.description = "A Ruby wrapper around the libev high performance event library"
11
- gem.email = "tony@medioh.com"
12
- gem.homepage = "http://github.com/tarcieri/cool.io"
13
- gem.authors = ["Tony Arcieri"]
14
- gem.add_dependency "iobuffer", ">= 0.1.3"
15
- gem.add_development_dependency "rspec", ">= 2.1.0"
16
- gem.extensions = FileList["ext/**/extconf.rb"].to_a
17
-
18
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
- end
20
- Jeweler::GemcutterTasks.new
21
- rescue LoadError
22
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
23
- end
24
-
25
4
  require 'rspec/core/rake_task'
26
- RSpec::Core::RakeTask.new(:spec) do |spec|
27
- spec.pattern = 'spec/**/*_spec.rb'
28
- spec.rspec_opts = %w[-fs -c -b]
29
- end
5
+ RSpec::Core::RakeTask.new
30
6
 
31
- RSpec::Core::RakeTask.new(:rcov) do |spec|
32
- spec.pattern = 'spec/**/*_spec.rb'
33
- spec.rcov = true
34
- spec.rspec_opts = %w[-fs -c -b]
7
+ RSpec::Core::RakeTask.new(:rcov) do |task|
8
+ task.rcov = true
35
9
  end
36
10
 
37
11
  task :default => %w(compile spec)
38
- task :spec => :check_dependencies
39
12
 
40
- require 'rake/rdoctask'
13
+ require 'rdoc/task'
41
14
  Rake::RDocTask.new do |rdoc|
42
15
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
43
16
 
@@ -47,42 +20,14 @@ Rake::RDocTask.new do |rdoc|
47
20
  rdoc.rdoc_files.include('lib/**/*.rb')
48
21
  end
49
22
 
50
- def make(makedir)
51
- Dir.chdir(makedir) { sh 'make' }
23
+ require 'rake/extensiontask'
24
+ Rake::ExtensionTask.new('http11_client') do |ext|
52
25
  end
53
26
 
54
- def extconf(dir)
55
- Dir.chdir(dir) { ruby "extconf.rb" }
27
+ Rake::ExtensionTask.new('cool.io_ext') do |ext|
28
+ ext.ext_dir = 'ext/cool.io'
56
29
  end
57
30
 
58
- def setup_extension(dir, extension)
59
- ext = "ext/#{dir}"
60
- ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
61
- ext_files = FileList[
62
- "#{ext}/*.c",
63
- "#{ext}/*.h",
64
- "#{ext}/extconf.rb",
65
- "#{ext}/Makefile",
66
- ]
67
-
68
- desc "Builds just the #{extension} extension"
69
- task extension.to_sym => ["#{ext}/Makefile", ext_so ]
70
-
71
- file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
72
- extconf "#{ext}"
73
- end
74
-
75
- file ext_so => ext_files do
76
- make "#{ext}"
77
- cp ext_so, "lib"
78
- end
79
- end
80
-
81
- setup_extension("cool.io", "cool.io_ext")
82
- setup_extension("http11_client", "http11_client")
83
-
84
- task :compile => %w(cool.io_ext http11_client)
85
-
86
31
  # Rebuild parser Ragel
87
32
  task :http11_parser do
88
33
  Dir.chdir "ext/http11_client" do
@@ -93,6 +38,25 @@ task :http11_parser do
93
38
  end
94
39
  end
95
40
 
96
- CLEAN.include ["build/*", "**/*.o", "**/*.so", "**/*.a", "**/*.log", "pkg"]
97
- CLEAN.include ["ext/**/Makefile", "lib/cool.io_ext.*", "lib/http11_client.*"]
98
- CLEAN.include ["ext/**/*.#{Config::CONFIG["DLEXT"]}"]
41
+ # adapted from http://flavoriffic.blogspot.com/2009/06/easily-valgrind-gdb-your-ruby-c.html
42
+ def specs_command
43
+ require "find"
44
+ files = []
45
+ Find.find("spec") do |f|
46
+ files << f if File.basename(f) =~ /.*spec.*\.rb$/
47
+ end
48
+ cmdline = "#{RUBY} -I.:lib:ext:spec \
49
+ -e '%w[#{files.join(' ')}].each { |f| require f }'"
50
+ end
51
+
52
+ namespace :spec do
53
+ desc "run specs with valgrind"
54
+ task :valgrind => :compile do
55
+ system "valgrind --num-callers=15 \
56
+ --partial-loads-ok=yes --undef-value-errors=no \
57
+ --tool=memcheck --leak-check=yes --track-fds=yes \
58
+ --show-reachable=yes #{specs_command}"
59
+ end
60
+ end
61
+
62
+ CLEAN.include "**/*.rbc", "**/*.o", "**/*.so", "**/*.bundle"