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.
- data/eventmachine.gemspec +1 -1
- data/ext/em.cpp +17 -16
- metadata +1 -1
data/eventmachine.gemspec
CHANGED
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
|
-
|
2174
|
-
struct inotify_event event;
|
2175
|
-
char buffer[256];
|
2176
|
-
};
|
2175
|
+
char buffer[1024];
|
2177
2176
|
|
2178
2177
|
assert(EventCallback);
|
2179
2178
|
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
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
|
}
|