rev 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,15 @@
1
+ 0.3.1:
2
+
3
+ * Configurable intervals for Rev::StatWatcher
4
+
5
+ * Fix broken version number :(
6
+
7
+ * Removed warning about spuriously readable sockets from Rev::Listener
8
+
9
+ * Rev::Listener ignores ECONNABORTED from accept_nonblock
10
+
11
+ * Document rationale for EAGAIN/ECONNABORTED handling in Rev::Listener
12
+
1
13
  0.3.0:
2
14
 
3
15
  * Add Rev::StatWatcher to monitor filesystem changes
@@ -16,7 +16,7 @@ static VALUE cRev_Watcher = Qnil;
16
16
  static VALUE cRev_StatWatcher = Qnil;
17
17
  static VALUE cRev_Loop = Qnil;
18
18
 
19
- static VALUE Rev_StatWatcher_initialize(VALUE self, VALUE path);
19
+ static VALUE Rev_StatWatcher_initialize(int argc, VALUE *argv, VALUE self);
20
20
  static VALUE Rev_StatWatcher_attach(VALUE self, VALUE loop);
21
21
  static VALUE Rev_StatWatcher_detach(VALUE self);
22
22
  static VALUE Rev_StatWatcher_enable(VALUE self);
@@ -39,7 +39,7 @@ void Init_rev_stat_watcher()
39
39
  cRev_StatWatcher = rb_define_class_under(mRev, "StatWatcher", cRev_Watcher);
40
40
  cRev_Loop = rb_define_class_under(mRev, "Loop", rb_cObject);
41
41
 
42
- rb_define_method(cRev_StatWatcher, "initialize", Rev_StatWatcher_initialize, 1);
42
+ rb_define_method(cRev_StatWatcher, "initialize", Rev_StatWatcher_initialize, -1);
43
43
  rb_define_method(cRev_StatWatcher, "attach", Rev_StatWatcher_attach, 1);
44
44
  rb_define_method(cRev_StatWatcher, "detach", Rev_StatWatcher_detach, 0);
45
45
  rb_define_method(cRev_StatWatcher, "enable", Rev_StatWatcher_enable, 0);
@@ -50,15 +50,25 @@ void Init_rev_stat_watcher()
50
50
 
51
51
  /**
52
52
  * call-seq:
53
- * Rev::StatWatcher.initialize(path) -> Rev::StatWatcher
53
+ * Rev::StatWatcher.initialize(path, interval = 0) -> Rev::StatWatcher
54
54
  *
55
55
  * Create a new Rev::StatWatcher for the given path. This will monitor the
56
- * given path for changes at the filesystem level.
56
+ * given path for changes at the filesystem level. The interval argument
57
+ * specified how often in seconds the path should be polled for changes.
58
+ * Setting interval to zero uses an "automatic" value (typically around 5
59
+ * seconds) which optimizes performance. Otherwise, values less than
60
+ * 0.1 are not particularly meaningful. Where available (at present, on Linux)
61
+ * high performance file monitoring interfaces will be used instead of polling.
57
62
  */
58
- static VALUE Rev_StatWatcher_initialize(VALUE self, VALUE path)
63
+ static VALUE Rev_StatWatcher_initialize(int argc, VALUE *argv, VALUE self)
59
64
  {
65
+ VALUE path, interval;
60
66
  struct Rev_Watcher *watcher_data;
61
67
 
68
+ rb_scan_args(argc, argv, "11", &path, &interval);
69
+ if(interval != Qnil)
70
+ interval = rb_convert_type(interval, T_FLOAT, "Float", "to_f");
71
+
62
72
  path = rb_String(path);
63
73
  rb_iv_set(self, "@path", path);
64
74
 
@@ -69,7 +79,7 @@ static VALUE Rev_StatWatcher_initialize(VALUE self, VALUE path)
69
79
  &watcher_data->event_types.ev_stat,
70
80
  Rev_StatWatcher_libev_callback,
71
81
  RSTRING_PTR(path),
72
- 0
82
+ interval == Qnil ? 0 : NUM2DBL(interval)
73
83
  );
74
84
  watcher_data->event_types.ev_stat.data = (void *)self;
75
85
 
@@ -179,4 +189,4 @@ static void Rev_StatWatcher_libev_callback(struct ev_loop *ev_loop, struct ev_st
179
189
  static void Rev_StatWatcher_dispatch_callback(VALUE self, int revents)
180
190
  {
181
191
  rb_funcall(self, rb_intern("on_change"), 0, 0);
182
- }
192
+ }
data/lib/rev.rb CHANGED
@@ -23,6 +23,6 @@ require 'iobuffer'
23
23
  end
24
24
 
25
25
  module Rev
26
- Rev::VERSION = '0.2.3' unless defined? Rev::VERSION
26
+ Rev::VERSION = '0.3.1' unless defined? Rev::VERSION
27
27
  def self.version() VERSION end
28
28
  end
@@ -39,8 +39,16 @@ module Rev
39
39
  def on_readable
40
40
  begin
41
41
  on_connection @listen_socket.accept_nonblock
42
- rescue Errno::EAGAIN
43
- STDERR.puts "warning: listener socket spuriously readable"
42
+ rescue Errno::EAGAIN, Errno::ECONNABORTED
43
+ # EAGAIN can be triggered here if the socket is shared between
44
+ # multiple processes and a thundering herd is woken up to accept
45
+ # one connection, only one process will get the connection and
46
+ # the others will be awoken.
47
+ # ECONNABORTED is documented in accept() manpages but modern TCP
48
+ # stacks with syncookies and/or accept()-filtering for DoS
49
+ # protection do not see it. In any case this error is harmless
50
+ # and we should instead spend our time with clients that follow
51
+ # through on connection attempts.
44
52
  end
45
53
  end
46
54
  end
@@ -2,10 +2,10 @@ require 'rubygems'
2
2
 
3
3
  GEMSPEC = Gem::Specification.new do |s|
4
4
  s.name = "rev"
5
- s.version = "0.3.0"
5
+ s.version = "0.3.1"
6
6
  s.authors = "Tony Arcieri"
7
7
  s.email = "tony@medioh.com"
8
- s.date = "2009-08-26"
8
+ s.date = "2009-10-13"
9
9
  s.summary = "Rev is a Ruby binding to the libev high performance event library"
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.required_ruby_version = '>= 1.8.6'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-26 00:00:00 -06:00
12
+ date: 2009-10-13 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency