smparkes-eventmachine 0.12.10 → 0.12.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/eventmachine.gemspec +1 -1
  2. data/ext/em.cpp +17 -16
  3. metadata +1 -1
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"
5
+ s.version = "0.12.10.1"
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
@@ -2133,6 +2133,7 @@ EventMachine_t::UnwatchFile
2133
2133
 
2134
2134
  void EventMachine_t::UnwatchFile (int wd)
2135
2135
  {
2136
+ // fprintf(stderr, "unwatch wd %d\n", wd);
2136
2137
  Bindable_t *b = Files[wd];
2137
2138
  assert(b);
2138
2139
  Files.erase(wd);
@@ -2152,6 +2153,7 @@ void EventMachine_t::UnwatchFile (int wd)
2152
2153
 
2153
2154
  void EventMachine_t::UnwatchFile (const unsigned long sig)
2154
2155
  {
2156
+ // fprintf(stderr, "unwatch sig %lu\n", sig);
2155
2157
  for(map<int, Bindable_t*>::iterator i=Files.begin(); i != Files.end(); i++)
2156
2158
  {
2157
2159
  if (i->second->GetBinding() == sig) {
@@ -2170,26 +2172,25 @@ EventMachine_t::_ReadInotify_Events
2170
2172
  void EventMachine_t::_ReadInotifyEvents()
2171
2173
  {
2172
2174
  #ifdef HAVE_INOTIFY
2173
- union {
2174
- struct inotify_event event;
2175
- char buffer[256];
2176
- };
2175
+ char buffer[1024];
2177
2176
 
2178
2177
  assert(EventCallback);
2179
2178
 
2180
- while (read(inotify->GetSocket(), buffer, sizeof(buffer) ) > 0) {
2181
- // fprintf(stderr,"%08x %08x\n",event.mask, event.mask & (IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVE));
2182
- // assert(event.len == 0);
2183
- if (event.mask & (IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVE)){
2184
- // fprintf(stderr,"%08x\n",event.mask);
2185
- (*EventCallback)(Files [event.wd]->GetBinding(), EM_CONNECTION_READ, "modified", 8);
2179
+ int returned;
2180
+ while ((returned = read(inotify->GetSocket(), buffer, sizeof(buffer) )) > 0) {
2181
+ int current = 0;
2182
+ while(current< returned){
2183
+ struct inotify_event* event = (struct inotify_event*)(buffer+current);
2184
+ if (event->mask & (IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVE))
2185
+ (*EventCallback)(Files [event->wd]->GetBinding(), EM_CONNECTION_READ, "modified", 8);
2186
+ if (event->mask & IN_MOVE_SELF)
2187
+ (*EventCallback)(Files [event->wd]->GetBinding(), EM_CONNECTION_READ, "moved", 5);
2188
+ if (event->mask & IN_DELETE_SELF) {
2189
+ (*EventCallback)(Files [event->wd]->GetBinding(), EM_CONNECTION_READ, "deleted", 7);
2190
+ UnwatchFile ((int)event->wd);
2191
+ }
2192
+ current += sizeof(struct inotify_event) + event->len;
2186
2193
  }
2187
- if (event.mask & IN_MOVE_SELF)
2188
- (*EventCallback)(Files [event.wd]->GetBinding(), EM_CONNECTION_READ, "moved", 5);
2189
- if (event.mask & IN_DELETE_SELF) {
2190
- (*EventCallback)(Files [event.wd]->GetBinding(), EM_CONNECTION_READ, "deleted", 7);
2191
- UnwatchFile ((int)event.wd);
2192
- }
2193
2194
  }
2194
2195
  #endif
2195
2196
  }
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
4
+ version: 0.12.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Cianfrocca