Chromium Code Reviews| Index: runtime/bin/file_system_watcher_android.cc |
| diff --git a/runtime/bin/file_system_watcher_android.cc b/runtime/bin/file_system_watcher_android.cc |
| index 333bc86c8e9c08e136f9487220db589e1156aa47..5971ed0ad8cd63cd537fc0d0262c34843d9c1c97 100644 |
| --- a/runtime/bin/file_system_watcher_android.cc |
| +++ b/runtime/bin/file_system_watcher_android.cc |
| @@ -25,10 +25,14 @@ intptr_t FileSystemWatcher::WatchPath(const char* path, |
| int events, |
| bool recursive) { |
| int fd = TEMP_FAILURE_RETRY(inotify_init()); |
|
Søren Gjesse
2013/10/30 14:05:51
Please add a comment on why this fd is blocking.
Anders Johnsen
2013/10/30 14:17:22
Done.
|
| - if (fd < 0 || !FDUtils::SetNonBlocking(fd) || !FDUtils::SetCloseOnExec(fd)) { |
| + if (fd < 0 || !FDUtils::SetCloseOnExec(fd)) { |
| return -1; |
| } |
| - int list_events = 0; |
| + // Some systems dosn't support setting this as non-blocking. Since watching |
| + // internals are kept away from the user, we know it's possible to continue, |
| + // even if setting non-blocking fails. |
| + FDUtils::SetNonBlocking(fd); |
| + int list_events = IN_DELETE_SELF | IN_MOVE_SELF; |
| if (events & kCreate) list_events |= IN_CREATE; |
| if (events & kModifyContent) list_events |= IN_MODIFY | IN_ATTRIB; |
| if (events & kDelete) list_events |= IN_DELETE; |
| @@ -69,11 +73,13 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id) { |
| reinterpret_cast<struct inotify_event*>(buffer + offset); |
| Dart_Handle event = Dart_NewList(4); |
| int mask = 0; |
| - if (e->mask & IN_MODIFY) mask |= kModifyContent; |
| + if (e->mask & IN_CLOSE_WRITE) mask |= kModifyContent; |
| if (e->mask & IN_ATTRIB) mask |= kModefyAttribute; |
| if (e->mask & IN_CREATE) mask |= kCreate; |
| if (e->mask & IN_MOVE) mask |= kMove; |
| if (e->mask & IN_DELETE) mask |= kDelete; |
| + if (e->mask & (IN_DELETE_SELF | IN_MOVE_SELF)) mask |= kDeleteSelf; |
| + if (e->mask & IN_ISDIR) mask |= kIsDir; |
| Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); |
| Dart_ListSetAt(event, 1, Dart_NewInteger(e->cookie)); |
| if (e->len > 0) { |