smparkes-eventmachine 0.12.10.1 → 0.12.10.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -13,3 +13,4 @@ Makefile
13
13
  *.pdb
14
14
  *.dSYM
15
15
  java/src/.project
16
+ /*eventmachine*.gem
data/eventmachine.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{smparkes-eventmachine}
5
- s.version = "0.12.10.1"
5
+ s.version = "0.12.10.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Francis Cianfrocca"]
data/ext/em.cpp CHANGED
@@ -133,6 +133,7 @@ EventMachine_t::~EventMachine_t()
133
133
  // Remove any file watch descriptors
134
134
  while(!Files.empty()) {
135
135
  map<int, Bindable_t*>::iterator f = Files.begin();
136
+ // fprintf(stderr,"unwatch ~ %d\n", f->first);
136
137
  UnwatchFile (f->first);
137
138
  }
138
139
 
@@ -2100,6 +2101,8 @@ const unsigned long EventMachine_t::WatchFile (const char *fpath)
2100
2101
  sprintf(errbuf, "failed to open file %s for registering with inotify: %s", fpath, strerror(errno));
2101
2102
  throw std::runtime_error(errbuf);
2102
2103
  }
2104
+
2105
+ // fprintf(stderr, "watch wd %d %s\n", wd,fpath);
2103
2106
  #endif
2104
2107
 
2105
2108
  #ifdef HAVE_KQUEUE
@@ -2118,7 +2121,9 @@ const unsigned long EventMachine_t::WatchFile (const char *fpath)
2118
2121
 
2119
2122
  if (wd != -1) {
2120
2123
  Bindable_t* b = new Bindable_t();
2124
+ // fprintf(stderr,"> insert %d %08x %08x\n",wd,Files[wd],b);
2121
2125
  Files.insert(make_pair (wd, b));
2126
+ // fprintf(stderr,"< insert %d %08x %08x %d\n",wd,Files[wd],b,Files.size());
2122
2127
 
2123
2128
  return b->GetBinding();
2124
2129
  }
@@ -2133,10 +2138,11 @@ EventMachine_t::UnwatchFile
2133
2138
 
2134
2139
  void EventMachine_t::UnwatchFile (int wd)
2135
2140
  {
2136
- // fprintf(stderr, "unwatch wd %d\n", wd);
2141
+ // fprintf(stderr, "unwatch wd %d\n", wd);
2137
2142
  Bindable_t *b = Files[wd];
2138
2143
  assert(b);
2139
2144
  Files.erase(wd);
2145
+ // fprintf(stderr, "< unwatch wd %d %d\n", wd,Files.count(wd));
2140
2146
 
2141
2147
  #ifdef HAVE_INOTIFY
2142
2148
  inotify_rm_watch(inotify->GetSocket(), wd);
@@ -2176,22 +2182,39 @@ void EventMachine_t::_ReadInotifyEvents()
2176
2182
 
2177
2183
  assert(EventCallback);
2178
2184
 
2185
+ // fprintf(stderr,"<> %d\n",Files.size());
2186
+
2179
2187
  int returned;
2180
2188
  while ((returned = read(inotify->GetSocket(), buffer, sizeof(buffer) )) > 0) {
2181
2189
  int current = 0;
2182
2190
  while(current< returned){
2183
2191
  struct inotify_event* event = (struct inotify_event*)(buffer+current);
2184
- if (event->mask & (IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVE))
2192
+ if(Files.count(event->wd)>0){
2193
+ Bindable_t* bt = Files[event->wd];
2194
+ fprintf(stderr,"%08x %d %d %d %d %08x %x\n",buffer+current,current,event->len,returned,event->wd,bt,event->mask);
2195
+ } else {
2196
+ fprintf(stderr,"%08x %d %d %d %d %08x %x\n",buffer+current,current,event->len,returned,event->wd,0,event->mask);
2197
+ }
2198
+ if (event->mask & (IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVE)){
2199
+ assert(Files[event->wd]);
2185
2200
  (*EventCallback)(Files [event->wd]->GetBinding(), EM_CONNECTION_READ, "modified", 8);
2186
- if (event->mask & IN_MOVE_SELF)
2201
+ }
2202
+ if (event->mask & IN_MOVE_SELF){
2203
+ assert(Files[event->wd]);
2187
2204
  (*EventCallback)(Files [event->wd]->GetBinding(), EM_CONNECTION_READ, "moved", 5);
2205
+ }
2188
2206
  if (event->mask & IN_DELETE_SELF) {
2207
+ assert(Files[event->wd]);
2189
2208
  (*EventCallback)(Files [event->wd]->GetBinding(), EM_CONNECTION_READ, "deleted", 7);
2209
+ fprintf(stderr,"implicit\n");
2190
2210
  UnwatchFile ((int)event->wd);
2211
+ // fprintf(stderr,"< implicit %d %d\n", event->wd, Files.count(event->wd));
2191
2212
  }
2213
+ fprintf(stderr,"%08x done\n",buffer+current);
2192
2214
  current += sizeof(struct inotify_event) + event->len;
2193
2215
  }
2194
2216
  }
2217
+ // fprintf(stderr,">< %d\n",Files.size());
2195
2218
  #endif
2196
2219
  }
2197
2220
 
data/lib/eventmachine.rb CHANGED
@@ -189,7 +189,7 @@ module EventMachine
189
189
  end
190
190
  @next_tick_mutex = Mutex.new
191
191
  @reactor_running = false
192
- @next_tick_queue = nil
192
+ @next_tick_queue = []
193
193
  @threadpool = nil
194
194
 
195
195
 
@@ -274,7 +274,7 @@ module EventMachine
274
274
  @threadpool = nil
275
275
  end
276
276
 
277
- @next_tick_queue = nil
277
+ @next_tick_queue = []
278
278
  end
279
279
  @reactor_running = false
280
280
  @reactor_thread = nil
@@ -989,11 +989,10 @@ module EventMachine
989
989
  cback.call result if cback
990
990
  end
991
991
 
992
- jobs = @next_tick_mutex.synchronize do
992
+ @next_tick_mutex.synchronize do
993
993
  jobs, @next_tick_queue = @next_tick_queue, []
994
994
  jobs
995
- end
996
- jobs.each { |j| j.call }
995
+ end.each { |j| j.call }
997
996
  end
998
997
 
999
998
 
@@ -1092,7 +1091,7 @@ module EventMachine
1092
1091
  def self.next_tick pr=nil, &block
1093
1092
  raise ArgumentError, "no proc or block given" unless ((pr && pr.respond_to?(:call)) or block)
1094
1093
  @next_tick_mutex.synchronize do
1095
- (@next_tick_queue ||= []) << ( pr || block )
1094
+ @next_tick_queue << ( pr || block )
1096
1095
  end
1097
1096
  signal_loopbreak if reactor_running?
1098
1097
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smparkes-eventmachine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.10.1
4
+ version: 0.12.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Cianfrocca